Merge pull request #4450 from NoiceHax/fix/issue-4443
fix(2fa): gate two-factor auth when the encryption key is missing
This commit is contained in:
12 files changed
+183
-9
No files matched your search
@@ -506,5 +506,6 @@ export const messages: Record<string, string> = {
|
||||
twoFactorErrorAlreadyEnabled: 'message.two-factor-error-already-enabled',
|
||||
twoFactorErrorNotEnabled: 'message.two-factor-error-not-enabled',
|
||||
twoFactorErrorNoPendingSetup: 'message.two-factor-error-no-pending-setup',
|
||||
twoFactorErrorNotConfigured: 'message.two-factor-error-not-configured',
|
||||
replayMinDurationDescription: 'message.replay-min-duration-description',
|
||||
};
|
||||
@@ -58,7 +58,7 @@ interface TwoFactorSetupModalProps {
|
||||
}
|
||||
|
||||
export function TwoFactorSetupModal({ required, onClose }: TwoFactorSetupModalProps) {
|
||||
const { t, labels, messages } = useMessages();
|
||||
const { t, labels, messages, getErrorMessage } = useMessages();
|
||||
const [qrCodeDataUrl, setQrCodeDataUrl] = useState<string | null>(null);
|
||||
const [manualKey, setManualKey] = useState<string | null>(null);
|
||||
const [otpValue, setOtpValue] = useState('');
|
||||
@@ -79,7 +79,7 @@ export function TwoFactorSetupModal({ required, onClose }: TwoFactorSetupModalPr
|
||||
setQrCodeDataUrl(data.qrCodeDataUrl);
|
||||
setManualKey(data.manualKey);
|
||||
},
|
||||
onError: () => setError(t(messages.error)),
|
||||
onError: (err: any) => setError(getErrorMessage(err) || t(messages.error)),
|
||||
},
|
||||
);
|
||||
}, []);
|
||||
@@ -92,7 +92,7 @@ export function TwoFactorSetupModal({ required, onClose }: TwoFactorSetupModalPr
|
||||
const data: any = await confirm({ token });
|
||||
setBackupCodes(data.backupCodes);
|
||||
} catch (err: any) {
|
||||
setError(err.message || t(messages.error));
|
||||
setError(getErrorMessage(err) || t(messages.error));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user