@@ -63,47 +63,6 @@ const Login: React.FC = () => {
6363 return isValidEmail ( email ) && isValidPhoneNumber ( phone ) ;
6464 } ;
6565
66- // const handlePasskeyLogin = async () => {
67- // try {
68- // const response = await fetchWithAuth(`/webAuthn/login/start`, {
69- // method: 'POST',
70- // });
71-
72- // if (!response.ok) {
73- // console.error('Something went wrong getting webauthn options');
74- // return;
75- // }
76-
77- // const options = await response.json();
78- // const credential = await startAuthentication({ optionsJSON: options });
79-
80- // const verificationResponse = await fetchWithAuth(`/webAuthn/login/finish`, {
81- // method: 'POST',
82- // body: JSON.stringify({ assertionResponse: credential }),
83- // });
84-
85- // if (!verificationResponse.ok) {
86- // console.error('Failed to verify passkey');
87- // }
88-
89- // const verificationResult = await verificationResponse.json();
90-
91- // if (verificationResult.message === 'Success') {
92- // if (verificationResult.mfaLogin) {
93- // navigate('/mfaLogin');
94- // return;
95- // }
96- // await validateToken();
97- // navigate('/');
98- // return;
99- // } else {
100- // console.error('Passkey login failed:', verificationResult.message);
101- // }
102- // } catch (error) {
103- // console.error('Passkey login error:', error);
104- // }
105- // };
106-
10766 const register = async ( ) => {
10867 setFormErrors ( '' ) ;
10968
@@ -175,9 +134,9 @@ const Login: React.FC = () => {
175134 e . preventDefault ( ) ;
176135
177136 if ( mode === 'login' ) {
178- login ( identifier , passkeyAvailable ) ;
137+ const loginRes = await login ( identifier , passkeyAvailable ) ;
179138
180- if ( passkeyAvailable ) {
139+ if ( loginRes . ok && passkeyAvailable ) {
181140 const passkeyResult = await handlePasskeyLogin ( ) ;
182141 if ( passkeyResult ) {
183142 navigate ( '/' ) ;
0 commit comments