Fix storing passkeys
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled

This commit is contained in:
Dan Milne
2025-11-04 16:32:50 +11:00
parent 57abc0b804
commit ec13dd2b60
2 changed files with 7 additions and 3 deletions

View File

@@ -146,9 +146,13 @@ class SessionsController < ApplicationController
begin
# Generate authentication options
# The WebAuthn gem will handle base64url encoding automatically
# Decode the stored base64url credential IDs before passing to the gem
credential_ids = user.webauthn_credentials.pluck(:external_id).map do |encoded_id|
Base64.urlsafe_decode64(encoded_id)
end
options = WebAuthn::Credential.options_for_get(
allow: user.webauthn_credentials.pluck(:external_id),
allow: credential_ids,
user_verification: "preferred"
)