Module: Devise::Passkeys::Controllers::PasskeysControllerConcern

Extended by:
ActiveSupport::Concern
Defined in:
lib/devise/passkeys/controllers/passkeys_controller_concern.rb

Instance Method Summary collapse

Instance Method Details

#createObject



54
55
56
# File 'lib/devise/passkeys/controllers/passkeys_controller_concern.rb', line 54

def create
  create_passkey(resource: resource)
end

#destroyObject



69
70
71
72
# File 'lib/devise/passkeys/controllers/passkeys_controller_concern.rb', line 69

def destroy
  @passkey.destroy
  redirect_to root_path
end

#new_create_challengeObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/devise/passkeys/controllers/passkeys_controller_concern.rb', line 42

def new_create_challenge
  options_for_registration = generate_registration_options(
    relying_party: relying_party,
    user_details: user_details_for_registration,
    exclude: exclude_external_ids_for_registration
  )

  store_challenge_in_session(options_for_registration: options_for_registration)

  render json: options_for_registration
end

#new_destroy_challengeObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/devise/passkeys/controllers/passkeys_controller_concern.rb', line 58

def new_destroy_challenge
  allowed_passkeys = (resource.passkeys - [@passkey])

  options_for_authentication = generate_authentication_options(relying_party: relying_party,
                                                               options: { allow: allowed_passkeys.pluck(:external_id) })

  store_reauthentication_challenge_in_session(options_for_authentication: options_for_authentication)

  render json: options_for_authentication
end