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
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/devise/second_factor_webauthn_credentials_controller.rb', line 9 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_create_path rescue WebAuthn::Error :alert, :webauthn_credential_verification_failed, scope: :"devise.failure" redirect_to after_create_path ensure session.delete(:webauthn_challenge) end |
#destroy ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/devise/second_factor_webauthn_credentials_controller.rb', line 35 def destroy if resource.second_factor_webauthn_credentials.destroy(params[:id]) :notice, :security_key_deleted else :alert, :security_key_deletion_failed, scope: :"devise.failure" end redirect_to after_destroy_path end |
#new ⇒ Object
7 |
# File 'app/controllers/devise/second_factor_webauthn_credentials_controller.rb', line 7 def new; end |
#update ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/devise/second_factor_webauthn_credentials_controller.rb', line 25 def update if resource.second_factor_webauthn_credentials.find(params[:id]).update(authentication_factor: 0) :notice, :security_key_promoted else :alert, :security_key_promotion_failed, scope: :"devise.failure" end redirect_to after_update_path end |