Skip to content

Commit dd3d003

Browse files
authored
fix: superadmin 2FA flow minors (#1548)
1 parent 7fd9466 commit dd3d003

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

components/guards/SetupMFA.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,27 @@ const SetupMFA = () => {
7878
setError('');
7979

8080
try {
81-
await reauthenticateUser(password);
81+
const reauthenticateResponse = await reauthenticateUser(password);
82+
if (reauthenticateResponse.error) {
83+
rollbar.error('Reauthentication error:', error);
84+
if (reauthenticateResponse.error.code === 'auth/wrong-password') {
85+
setError(t('form.firebase.wrongPassword'));
86+
} else if (reauthenticateResponse.error.code === 'auth/too-many-requests') {
87+
setError(t('form.firebase.tooManyAttempts'));
88+
} else {
89+
setError(t('form.reauthenticationError'));
90+
}
91+
return;
92+
}
93+
// Reauthenticate success
8294
setShowReauth(false);
8395
setPassword('');
8496
// Reset the MFA setup process
8597
setVerificationId('');
8698
setVerificationCode('');
87-
// Don't reset phone number - it will be restored from storedPhoneNumber
8899
} catch (error: any) {
89100
rollbar.error('Reauthentication error:', error);
90-
if (error.code === 'auth/wrong-password') {
91-
setError(t('form.firebase.wrongPassword'));
92-
} else if (error.code === 'auth/too-many-requests') {
93-
setError(t('form.firebase.tooManyAttempts'));
94-
} else {
95-
setError(t('form.reauthenticationError'));
96-
}
101+
setError(t('form.reauthenticationError'));
97102
} finally {
98103
setIsReauthenticating(false);
99104
}
@@ -230,7 +235,6 @@ const SetupMFA = () => {
230235
color="secondary"
231236
sx={{ ...buttonStyle, mt: 2 }}
232237
onClick={handleSendVerificationEmail}
233-
disabled={emailVerificationSent}
234238
>
235239
{emailVerificationSent
236240
? t('form.resendVerificationEmail')

0 commit comments

Comments
 (0)