Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
credentials: Credential[];
updateCredential: (credential: Credential) => Promise<Credential>;
deleteCredential: (credentialId: string) => Promise<void>;
login: (identifier: string, passkeyAvailable: boolean) => Promise<Response>;
login: (identifier: string, passkeyAvailable: boolean) => Promise<Response | null>;
handlePasskeyLogin: () => Promise<boolean>;
loading: boolean;
}
Expand Down Expand Up @@ -109,13 +109,19 @@
const login = async (
identifier: string,
passkeyAvailable: boolean
): Promise<Response> => {
const response = await fetchWithAuth(`/login`, {
method: 'POST',
body: JSON.stringify({ identifier, passkeyAvailable }),
});
): Promise<Response | null> => {
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 () => {
Expand Down Expand Up @@ -247,7 +253,7 @@

useEffect(() => {
validateToken();
}, []);

Check warning on line 256 in src/AuthProvider.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useEffect has a missing dependency: 'validateToken'. Either include it or remove the dependency array

useEffect(() => {
if (user && isAuthenticated) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/AuthFallbackOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const AuthFallbackOptions: React.FC<AuthFallbackOptionsProps> = ({

return (
<div className={styles.fallbackCard}>
<div className={styles.fallbackHeader}>Passkeys unavailable on this device</div>
<div className={styles.fallbackHeader}>Trouble with passkey login?</div>

<p className={styles.fallbackDescription}>Choose another secure sign-in method.</p>

Expand Down
4 changes: 3 additions & 1 deletion src/views/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Loading