Class: Devise::SecondFactorWebauthnCredentialsController
- Inherits:
-
DeviseController
- Object
- DeviseController
- Devise::SecondFactorWebauthnCredentialsController
- Defined in:
- app/controllers/devise/second_factor_webauthn_credentials_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/devise/second_factor_webauthn_credentials_controller.rb', line 24 def create security_key_from_params = WebAuthn::Credential.from_create(JSON.parse(params[:public_key_credential])) if verify_and_save_security_key(security_key_from_params) :notice, :security_key_created else :alert, :webauthn_credential_verification_failed, scope: :"devise.failure" end redirect_to after_update_path rescue WebAuthn::Error :alert, :webauthn_credential_verification_failed, scope: :"devise.failure" redirect_to after_update_path ensure session.delete(:webauthn_challenge) end |
#destroy ⇒ Object
40 41 42 43 |
# File 'app/controllers/devise/second_factor_webauthn_credentials_controller.rb', line 40 def destroy resource.second_factor_webauthn_credentials.destroy(params[:id]) redirect_to after_update_path end |
#new ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/devise/second_factor_webauthn_credentials_controller.rb', line 7 def new @options = WebAuthn::Credential.( user: { id: resource.webauthn_id, name: resource.email }, exclude: resource.webauthn_credentials.pluck(:external_id), authenticator_selection: { resident_key: "discouraged", user_verification: "discouraged" } ) # Store challenge in session for later verification session[:webauthn_challenge] = @options.challenge end |