Class: Masks::Credentials::ReturnTo

Inherits:
Masks::Credential show all
Defined in:
app/models/masks/credentials/return_to.rb

Overview

Assigns the request URL to session data, under the key return_to.

This credential is intended to keep track of an actor’s attempts to access protected resources, so it only assigns the value if the session has not passed.

In some cases, you may want to selectively disable the functionality of this credential. To do so, set return_to to false in the mask configuration.

Instance Method Summary collapse

Methods inherited from Masks::Credential

#backup!, #check, checks, #cleanup, #cleanup!, #lookup, #mask!, #maskup, #name, #patch_params, #slug

Instance Method Details

#backupObject



15
16
17
18
19
20
21
22
23
24
# File 'app/models/masks/credentials/return_to.rb', line 15

def backup
  return if session&.passed?
  return unless session.try(:request) && session.request.get?
  if session.mask.extras.key?(:return_to) &&
       !session.mask.extras[:return_to]
    return
  end

  session.data[:return_to] = session.request.url
end