Make passkey login default

This commit is contained in:
DariusIII
2026-04-24 14:41:34 +02:00
parent 768cb0bf17
commit 5e7d62b1e2
3 changed files with 15 additions and 1 deletions
@@ -5,6 +5,7 @@ Alpine.data('passkeyLogin', () => ({
busy: false,
error: '',
showCreateHint: false,
hasAutoPrompted: false,
init() {
this.supported = typeof window.browserSupportsWebAuthn === 'function'
@@ -13,6 +14,18 @@ Alpine.data('passkeyLogin', () => ({
// If backend already reported an invalid passkey login attempt,
// immediately show the "sign in first, then create passkey" guidance.
this.showCreateHint = this.$el.dataset.serverPasskeyError === '1';
const shouldAutoPrompt = this.$el.dataset.autoPrompt === '1';
if (this.supported && shouldAutoPrompt && !this.showCreateHint) {
window.requestAnimationFrame(() => {
if (this.hasAutoPrompted || this.busy) {
return;
}
this.hasAutoPrompted = true;
void this.authenticate();
});
}
},
async authenticate() {
+1 -1
View File
@@ -43,7 +43,7 @@
@endif
<div x-show="!showPassword" x-cloak>
@include('partials.passkey-authenticate')
@include('partials.passkey-authenticate', ['autoPromptPasskey' => ! $errors->any()])
<button
type="button"
@@ -3,6 +3,7 @@
x-cloak
data-options-url="{{ route('passkeys.authentication_options') }}"
data-server-passkey-error="{{ session('authenticatePasskey::reason') === 'invalid_passkey' ? '1' : '0' }}"
data-auto-prompt="{{ ($autoPromptPasskey ?? true) ? '1' : '0' }}"
data-captcha-enabled="{{ \App\Support\CaptchaHelper::isEnabled() ? '1' : '0' }}"
data-captcha-field="{{ \App\Support\CaptchaHelper::isEnabled() ? \App\Support\CaptchaHelper::getResponseFieldName() : '' }}"
class="mt-6"