Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

add confirmation for enabling mfa

Thiago Araujo da Silvaedb6e7482270
diff --git a/frontend/src/components/mfa/setup/VerifyStep.tsx b/frontend/src/components/mfa/setup/VerifyStep.tsx
index 50ba50082b..b2d2004f25 100644
--- a/frontend/src/components/mfa/setup/VerifyStep.tsx
+++ b/frontend/src/components/mfa/setup/VerifyStep.tsx
@@ -35,11 +35,9 @@ const TotpVerify = ({ onVerified }: { onVerified: Props["onVerified"] }) => {
await enrollMfa({ method: MfaMethod.TOTP, totp: totp.trim() });
createNotification({ text: "Authenticator app configured", type: "success" });
await onVerified();
- } catch (error: any) {
- createNotification({
- text: error?.response?.data?.message || "Invalid verification code",
- type: "error"
- });
+ } catch {
+ // The mutation's global error handler already surfaces the (more detailed)
+ // failure toast; just swallow here so onVerified isn't called on failure.
}
};
diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx
index ea400e1da9..b7b3f7726d 100644
--- a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx
+++ b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx
@@ -49,6 +49,7 @@ export const MFASection = () => {
const isMfaEnforced = organizations.some((org) => org.enforceMfa);
+ const [isEnableOpen, setIsEnableOpen] = useState(false);
const [isDisableOpen, setIsDisableOpen] = useState(false);
// Holds the fresh recovery codes returned on enable so they can be shown once.
const [newRecoveryCodes, setNewRecoveryCodes] = useState<string[] | null>(null);
@@ -94,6 +95,7 @@ export const MFASection = () => {
const handleEnable = async () => {
try {
const { recoveryCodes } = await activateMfa({ selectedMfaMethod: selectedMethod });
+ setIsEnableOpen(false);
setNewRecoveryCodes(recoveryCodes);
} catch (error: any) {
createNotification({
@@ -204,7 +206,7 @@ export const MFASection = () => {
<p className="text-sm text-muted">
Choose your preferred method above, then enable two-factor authentication.
</p>
- <Button variant="org" isPending={isEnabling} onClick={handleEnable}>
+ <Button variant="org" isDisabled={isEnabling} onClick={() => setIsEnableOpen(true)}>
<ShieldCheckIcon /> Enable two-factor authentication
</Button>
</>
@@ -221,6 +223,25 @@ export const MFASection = () => {
{hasRecoveryCodes && <RecoveryOptionsCard />}
</div>
+ <AlertDialog open={isEnableOpen} onOpenChange={setIsEnableOpen}>
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Enable two-factor authentication?</AlertDialogTitle>
+ <AlertDialogDescription>
+ This turns on two-factor authentication using {MFA_METHOD_LABELS[selectedMethod]} as
+ your preferred method. You&apos;ll be shown a set of recovery codes to save right
+ after.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogAction variant="org" isPending={isEnabling} onClick={handleEnable}>
+ Enable
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+
<AlertDialog open={isDisableOpen} onOpenChange={setIsDisableOpen}>
<AlertDialogContent>
<AlertDialogHeader>