From 0f031de621a74ff2809ec71ba1f8e689dad160bf Mon Sep 17 00:00:00 2001 From: Peter Date: Tue, 14 Apr 2026 23:59:29 -0400 Subject: [PATCH] updated error message for passkey to be more generic, added a generic error text when trying to login with bad account --- src/AuthProvider.tsx | 20 +++++++++++++------- src/components/AuthFallbackOptions.tsx | 2 +- src/views/Login.tsx | 4 +++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/AuthProvider.tsx b/src/AuthProvider.tsx index 32a59a0..2afe2d3 100644 --- a/src/AuthProvider.tsx +++ b/src/AuthProvider.tsx @@ -48,7 +48,7 @@ export interface AuthContextType { credentials: Credential[]; updateCredential: (credential: Credential) => Promise; deleteCredential: (credentialId: string) => Promise; - login: (identifier: string, passkeyAvailable: boolean) => Promise; + login: (identifier: string, passkeyAvailable: boolean) => Promise; handlePasskeyLogin: () => Promise; loading: boolean; } @@ -109,13 +109,19 @@ export const AuthProvider: React.FC = ({ const login = async ( identifier: string, passkeyAvailable: boolean - ): Promise => { - const response = await fetchWithAuth(`/login`, { - method: 'POST', - body: JSON.stringify({ identifier, passkeyAvailable }), - }); + ): Promise => { + console.log('oranges'); - return response; + try { + const response = await fetchWithAuth(`/login`, { + method: 'POST', + body: JSON.stringify({ identifier, passkeyAvailable }), + }); + return response; + } catch (error) { + console.error('Error fetching,', error); + return null; + } }; const handlePasskeyLogin = async () => { diff --git a/src/components/AuthFallbackOptions.tsx b/src/components/AuthFallbackOptions.tsx index 5bd4907..e56f59e 100644 --- a/src/components/AuthFallbackOptions.tsx +++ b/src/components/AuthFallbackOptions.tsx @@ -27,7 +27,7 @@ const AuthFallbackOptions: React.FC = ({ return (
-
Passkeys unavailable on this device
+
Trouble with passkey login?

Choose another secure sign-in method.

diff --git a/src/views/Login.tsx b/src/views/Login.tsx index ce2c28a..180b108 100644 --- a/src/views/Login.tsx +++ b/src/views/Login.tsx @@ -155,12 +155,14 @@ const Login: React.FC = () => { if (mode === 'login') { const loginRes = await login(identifier, passkeyAvailable); - if (loginRes.ok && passkeyAvailable) { + if (loginRes && loginRes.ok && passkeyAvailable) { const passkeyResult = await handlePasskeyLogin(); + if (passkeyResult) { navigate('/'); } } else { + setIdentifierError('An error occurred'); setShowFallbackOptions(true); } }