From 8a42a0d040954eb0da78574ce9bb00a41a680998 Mon Sep 17 00:00:00 2001
From: roble
Date: Sat, 31 Oct 2026 20:42:18 +0000
Subject: [PATCH 1/2] feat: update passkey error handling and enhance password
update section in settings
---
composer.json | 2 +-
resources/js/lib/passkeyError.test.ts | 40 ++++++
resources/js/lib/passkeyError.ts | 23 +++
resources/js/react/pages/SettingsSecurity.tsx | 135 +++++++++--------
resources/js/vue/pages/SettingsSecurity.vue | 136 +++++++++---------
tests/e2e/tests/passkeys/passkeys.spec.ts | 13 ++
6 files changed, 207 insertions(+), 142 deletions(-)
create mode 100644 resources/js/lib/passkeyError.test.ts
create mode 100644 resources/js/lib/passkeyError.ts
diff --git a/composer.json b/composer.json
index 7fc9bf2..97ecc9b 100644
--- a/composer.json
+++ b/composer.json
@@ -37,7 +37,7 @@
}
},
"require": {
- "saucebase/core": "^2.7",
+ "saucebase/core": "^2.8",
"laravel/socialite": "^5.31",
"stechstudio/filament-impersonate": "^5.6.1",
"laravel/passkeys": "^0.2.1"
diff --git a/resources/js/lib/passkeyError.test.ts b/resources/js/lib/passkeyError.test.ts
new file mode 100644
index 0000000..96db24a
--- /dev/null
+++ b/resources/js/lib/passkeyError.test.ts
@@ -0,0 +1,40 @@
+import { describe, expect, it } from 'vitest';
+import { passkeyErrorMessage } from './passkeyError';
+
+const t = (key: string) => `t:${key}`;
+
+describe('passkeyErrorMessage', () => {
+ it('says nothing without an error', () => {
+ expect(passkeyErrorMessage(null, t)).toBeNull();
+ expect(passkeyErrorMessage(undefined, t)).toBeNull();
+ });
+
+ it('says nothing when the user closed the prompt', () => {
+ expect(
+ passkeyErrorMessage(
+ { name: 'UserCancelledError', message: 'Cancelled' },
+ t,
+ ),
+ ).toBeNull();
+ });
+
+ it('points to another device when this one already has a passkey', () => {
+ expect(
+ passkeyErrorMessage(
+ {
+ name: 'PasskeyExistsError',
+ message: 'This device is already registered as a passkey.',
+ },
+ t,
+ ),
+ ).toBe(
+ 't:This device already has a passkey. Add one from another device or a password manager.',
+ );
+ });
+
+ it('passes any other error through', () => {
+ expect(
+ passkeyErrorMessage({ name: 'Error', message: 'Server error' }, t),
+ ).toBe('Server error');
+ });
+});
diff --git a/resources/js/lib/passkeyError.ts b/resources/js/lib/passkeyError.ts
new file mode 100644
index 0000000..c931046
--- /dev/null
+++ b/resources/js/lib/passkeyError.ts
@@ -0,0 +1,23 @@
+/**
+ * What to tell the user when adding a passkey fails, or null to say nothing.
+ *
+ * Closing the browser's own prompt is a choice, not something to report. The
+ * package's "already registered" message is English only and says nothing about
+ * what to do next: the browser refuses a second passkey on the same authenticator.
+ */
+export function passkeyErrorMessage(
+ error: { name: string; message: string } | null | undefined,
+ t: (key: string) => string,
+): string | null {
+ if (!error || error.name === 'UserCancelledError') {
+ return null;
+ }
+
+ if (error.name === 'PasskeyExistsError') {
+ return t(
+ 'This device already has a passkey. Add one from another device or a password manager.',
+ );
+ }
+
+ return error.message;
+}
diff --git a/resources/js/react/pages/SettingsSecurity.tsx b/resources/js/react/pages/SettingsSecurity.tsx
index 45e0413..46a316e 100644
--- a/resources/js/react/pages/SettingsSecurity.tsx
+++ b/resources/js/react/pages/SettingsSecurity.tsx
@@ -1,3 +1,4 @@
+import { EmptyState } from '@/components/ui/saucebase';
import { Button } from '@/components/ui/button';
import { Field, FieldError, FieldLabel } from '@/components/ui/field';
import { Input } from '@/components/ui/input';
@@ -364,69 +365,9 @@ export default function SettingsSecurity({
)}
- {/* Password */}
-
-
-
{t('Update Password')}
-
- {t(
- 'Ensure your account is using a long, random password to stay secure.',
- )}
-
-
-
-
-
-
{/* Passkeys */}
{showPasskeys && (
<>
-
-
{t('Passkeys')}
@@ -546,22 +487,76 @@ export default function SettingsSecurity({
))}
) : (
-
}
data-testid="passkeys-empty"
- >
-
-
-
-
- {t('No passkeys yet.')}
-
-
+ />
)}
+
+
>
)}
+ {/* Password */}
+
+
+
{t('Update Password')}
+
+ {t(
+ 'Ensure your account is using a long, random password to stay secure.',
+ )}
+
+
+
+
+
+
{/* Connected accounts */}
{hasSocialiteProviders && (
<>
diff --git a/resources/js/vue/pages/SettingsSecurity.vue b/resources/js/vue/pages/SettingsSecurity.vue
index 5cd94c9..eb655c7 100644
--- a/resources/js/vue/pages/SettingsSecurity.vue
+++ b/resources/js/vue/pages/SettingsSecurity.vue
@@ -1,4 +1,5 @@