Class: Passkeys::OptionsController

Inherits:
ApplicationController
  • Object
show all
Includes:
PasskeyRelyingParty
Defined in:
lib/generators/action_passkey/install/templates/passkeys_options_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/action_passkey/install/templates/passkeys_options_controller.rb', line 4

def create
  options = passkey_relying_party.options_for_registration(
    user: {
      id: WebAuthn.standard_encoder.encode(Current.user.id.to_s),
      name: Current.user.email_address,
      display_name: Current.user.email_address
    },
    exclude: Current.user.passkeys.pluck(:external_id)
  )

  session[:passkey_registration_challenge] = options.challenge

  render json: options
end