Class: Booth::Userland::Sessions::Transitions::Destroy::WebauthAuthenticationInitiation

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.applicable?(params:) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/booth/userland/sessions/transitions/destroy/webauth_authentication_initiation.rb', line 11

def self.applicable?(params:)
  params[:webauth] && !params.key?(:handshake)
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/booth/userland/sessions/transitions/destroy/webauth_authentication_initiation.rb', line 15

def call
  log { 'Preparing webauth challenge...' }
  credential = ::Booth::Models::Credential.find(authentication.credential_id)
  challenging = Booth::Core::Credentials::WebauthChallenge.call(credential:, request:)
  result = Tron.success :webauth_for_you, public_json: challenging.options_for_get, http_status: :created
  log { "The challenge is #{challenging.challenge}" }
  sudo.webauthn_challenge = challenging.challenge
  log { "Responding with JSON: #{result.public_json}" }
  result
end