Class: PasskeyAuth::Webauthn::Authentications::ChallengesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- PasskeyAuth::Webauthn::Authentications::ChallengesController
- Defined in:
- app/controllers/passkey_auth/webauthn/authentications/challenges_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/passkey_auth/webauthn/authentications/challenges_controller.rb', line 14 def create if @user # Prepare the needed data for a challenge = ::WebAuthn::Credential.(allow: @user.webauthn_credentials.pluck(:external_id)) else # For conditional UI, we create options for authentication without knowing the user ahead of time # This allows the browser to prompt with available passkeys = ::WebAuthn::Credential.(user_verification: "required") end # Generate the challenge and save it into the session session[:webauthn_authentication_challenge] = .challenge respond_to do |format| format.json { render json: } end end |