Class: Booth::Userland::Sessions::Transitions::Destroy::EnterPassword

Inherits:
Object
  • Object
show all
Includes:
Concerns::Transition
Defined in:
lib/booth/userland/sessions/transitions/destroy/enter_password.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.applicable?(params:) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/booth/userland/sessions/transitions/destroy/enter_password.rb', line 9

def self.applicable?(params:)
  !params[:revocation]
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/booth/userland/sessions/transitions/destroy/enter_password.rb', line 13

def call
  if sudo.password?
    if session_id_param
      debug { 'Having password sudo, revoking the desired session...' }
      return ::Booth::Sessions::Revoke.call credential_id: authentication.credential_id,
                                            session_id: session_id_param
    else
      debug { 'Having password sudo, revoking all other sessions...' }
      return ::Booth::Sessions::RevokeAllOthers.call credential_id: authentication.credential_id,
                                                     surviving_session_id: authentication.session_id
    end
  end

  if session_id_param
    Tron.failure :need_sudo_to_destroy_session,
                 step: :enter_password_to_destroy,
                 session_id: session_id_param
  else
    Tron.failure :need_sudo_to_destroy_all_other_sessions,
                 step: :enter_password_to_destroy_all_others
  end
end

#session_id_paramObject



36
37
38
39
40
# File 'lib/booth/userland/sessions/transitions/destroy/enter_password.rb', line 36

def session_id_param
  # If params[:id] is a UUID, then it's an ID for a `Booth::Models::Session` in the DB.
  # If params[:id] is something else, then it's just a WebAuth Ceremony argument.
  ::Booth::Syntaxes::Uuid.call(request.params[:id], raise_if_invalid: false).uuid
end