Class: ActionAuth::Sessions::PasskeysController

Inherits:
ApplicationController show all
Defined in:
app/controllers/action_auth/sessions/passkeys_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/action_auth/sessions/passkeys_controller.rb', line 10

def create
  webauthn_credential = WebAuthn::Credential.from_get(params)
  credential = WebauthnCredential.find_by(external_id: webauthn_credential.id)
  user = User.find_by(id: credential&.user_id)
  if credential && user
    session = user.sessions.create
    cookies.signed.permanent[:session_token] = { value: session.id, httponly: true }
    redirect_to main_app.root_path(format: :html), notice: "Signed in successfully"
  else
    redirect_to (format: :html), alert: "That passkey is incorrect" and return
  end
end

#newObject



4
5
6
7
8
# File 'app/controllers/action_auth/sessions/passkeys_controller.rb', line 4

def new
  get_options = WebAuthn::Credential.options_for_get
  session[:current_challenge] = get_options.challenge
  @options = get_options
end