Class: Devise::PasskeysController

Inherits:
DeviseController
  • Object
show all
Defined in:
app/controllers/devise/passkeys_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/devise/passkeys_controller.rb', line 9

def create
  passkey_from_params = WebAuthn::Credential.from_create(JSON.parse(params[:public_key_credential]))

  if verify_and_save_passkey(passkey_from_params)
    set_flash_message! :notice, :passkey_created
  else
    set_flash_message! :alert, :passkey_verification_failed, scope: :"devise.failure"
  end
  redirect_to after_update_path
rescue WebAuthn::Error
  set_flash_message! :alert, :passkey_verification_failed, scope: :"devise.failure"
  redirect_to after_update_path
ensure
  session.delete(:webauthn_challenge)
end

#destroyObject



25
26
27
28
29
30
31
32
33
# File 'app/controllers/devise/passkeys_controller.rb', line 25

def destroy
  if resource.passkeys.destroy(params[:id])
    set_flash_message! :notice, :passkey_deleted
  else
    set_flash_message! :alert, :passkey_deletion_failed, scope: :"devise.failure"
  end

  redirect_to after_update_path
end

#newObject



7
# File 'app/controllers/devise/passkeys_controller.rb', line 7

def new; end