Class: Unmagic::Passkeys::CredentialsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/unmagic/passkeys/credentials_controller.rb

Overview

Passkey management for the signed-in holder: list (+index+), add (+create+), and remove (+destroy+). Requires authentication via the host's base controller. The holder comes from the configured current_holder hook.

Instance Method Summary collapse

Methods included from Request

#passkey_authentication_options, #passkey_authentication_params, #passkey_registration_options, #passkey_registration_params

Instance Method Details

#createObject



10
11
12
13
# File 'app/controllers/unmagic/passkeys/credentials_controller.rb', line 10

def create
  passkey_holder.passkeys.register(passkey_registration_params)
  redirect_to url_for(action: :index), notice: "Passkey added."
end

#destroyObject



15
16
17
18
# File 'app/controllers/unmagic/passkeys/credentials_controller.rb', line 15

def destroy
  passkey_holder.passkeys.find(params[:id]).destroy
  redirect_to url_for(action: :index), notice: "Passkey removed."
end

#indexObject



5
6
7
8
# File 'app/controllers/unmagic/passkeys/credentials_controller.rb', line 5

def index
  @passkeys = passkey_holder.passkeys.order(created_at: :desc)
  @registration_options = passkey_registration_options(holder: passkey_holder)
end