Skip to content

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

confirmation modal and same card for all 2fa configs

Thiago Araujo da Silva9b607a8a980c
diff --git a/frontend/src/components/mfa/setup/RecoveryCodesView.tsx b/frontend/src/components/mfa/setup/RecoveryCodesView.tsx
index 9c0bdcf51c..a84ac31ece 100644
--- a/frontend/src/components/mfa/setup/RecoveryCodesView.tsx
+++ b/frontend/src/components/mfa/setup/RecoveryCodesView.tsx
@@ -75,6 +75,7 @@ export const RecoveryCodesView = ({ recoveryCodes, onSaved, acknowledgment }: Pr
<div className="flex items-center gap-2">
<Checkbox
id="acknowledge-recovery-codes"
+ variant="org"
isChecked={acknowledgment.isAcknowledged}
onCheckedChange={(checked) => acknowledgment.onAcknowledgedChange(checked === true)}
/>
diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx
index 2d118d0447..56b4392791 100644
--- a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx
+++ b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx
@@ -125,7 +125,7 @@ export const MFASection = () => {
const handleDisable = () => disableMfa(() => setIsDisableOpen(false));
const banner = (
- <div className="rounded-lg border border-border bg-card p-6">
+ <div className="p-6">
<div className="flex items-start justify-between">
<h2 className="text-lg font-medium text-foreground">Two-factor Authentication</h2>
{user.isMfaEnabled ? (
@@ -194,7 +194,7 @@ export const MFASection = () => {
<p className="text-sm text-muted">
{isMfaEnforced
? "Your organization requires two-factor authentication, so it can't be disabled."
- : "Turning this off keeps your configured methods, but your recovery codes are invalidated and a new set is issued when you re-enable."}
+ : "Turning this off keeps your configured methods, but your recovery codes are invalidated."}
</p>
<Button
variant="danger"
@@ -226,10 +226,18 @@ export const MFASection = () => {
return (
<>
- <div className="mb-6 flex flex-col gap-6">
+ {/* One card, sectioned with separators, so the whole 2FA context reads as a
+ single unit rather than three disconnected cards. */}
+ <div className="mb-6 rounded-lg border border-border bg-card">
{banner}
- <MfaMethodsCard />
- {hasRecoveryCodes && <RecoveryOptionsCard />}
+ <div className="border-t border-border">
+ <MfaMethodsCard />
+ </div>
+ {hasRecoveryCodes && (
+ <div className="border-t border-border">
+ <RecoveryOptionsCard />
+ </div>
+ )}
</div>
<AlertDialog open={isEnableOpen} onOpenChange={setIsEnableOpen}>
diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MfaMethodsCard.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MfaMethodsCard.tsx
index 16ff602ae2..fdc40c482d 100644
--- a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MfaMethodsCard.tsx
+++ b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MfaMethodsCard.tsx
@@ -79,7 +79,7 @@ export const MfaMethodsCard = () => {
};
return (
- <div className="rounded-lg border border-border bg-card p-4">
+ <div className="p-6">
<h3 className="mb-2 text-sm font-medium text-foreground">Two-factor methods</h3>
<div className="divide-y divide-border">
<MethodRow
diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/PasskeyManagerDialog.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/PasskeyManagerDialog.tsx
index dd918fac62..e3d7854198 100644
--- a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/PasskeyManagerDialog.tsx
+++ b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/PasskeyManagerDialog.tsx
@@ -4,6 +4,14 @@ import { FingerprintIcon, PlusIcon, TrashIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import { ContentLoader } from "@app/components/v2";
import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
Button,
Input,
Sheet,
@@ -26,9 +34,12 @@ type Props = {
export const PasskeyManagerDialog = ({ isOpen, onOpenChange }: Props) => {
const { data: credentials = [], isPending } = useGetWebAuthnCredentials();
const { registerPasskey, isRegistering } = useRegisterPasskey();
- const { mutateAsync: deleteCredential } = useDeleteWebAuthnCredential();
+ const { mutateAsync: deleteCredential, isPending: isDeleting } = useDeleteWebAuthnCredential();
const [name, setName] = useState("");
+ const [credentialToRemove, setCredentialToRemove] = useState<{ id: string; name: string } | null>(
+ null
+ );
const handleAdd = async () => {
if (await registerPasskey(name)) {
@@ -36,9 +47,11 @@ export const PasskeyManagerDialog = ({ isOpen, onOpenChange }: Props) => {
}
};
- const handleDelete = async (id: string) => {
+ const handleDelete = async () => {
+ if (!credentialToRemove) return;
try {
- await deleteCredential({ id });
+ await deleteCredential({ id: credentialToRemove.id });
+ setCredentialToRemove(null);
createNotification({ text: "Passkey removed", type: "success" });
} catch (error: any) {
createNotification({
@@ -49,65 +62,96 @@ export const PasskeyManagerDialog = ({ isOpen, onOpenChange }: Props) => {
};
return (
- <Sheet open={isOpen} onOpenChange={onOpenChange}>
- <SheetContent side="right" className="flex flex-col gap-0 sm:max-w-lg">
- <SheetHeader className="border-b">
- <SheetTitle>Manage passkeys</SheetTitle>
- <SheetDescription>
- Passkeys use Face ID, Touch ID, a security key, or your device to sign in.
- </SheetDescription>
- </SheetHeader>
+ <>
+ <Sheet open={isOpen} onOpenChange={onOpenChange}>
+ <SheetContent side="right" className="flex flex-col gap-0 sm:max-w-lg">
+ <SheetHeader className="border-b">
+ <SheetTitle>Manage passkeys</SheetTitle>
+ <SheetDescription>
+ Passkeys use Face ID, Touch ID, a security key, or your device to sign in.
+ </SheetDescription>
+ </SheetHeader>
- <div className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-5">
- <div className="flex items-end gap-2">
- <div className="flex-1">
- <Input
- value={name}
- onChange={(e) => setName(e.target.value)}
- placeholder="New passkey name (optional)"
- />
+ <div className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-5">
+ <div className="flex items-end gap-2">
+ <div className="flex-1">
+ <Input
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ placeholder="New passkey name (optional)"
+ />
+ </div>
+ <Button variant="org" isPending={isRegistering} onClick={handleAdd}>
+ <PlusIcon /> Add
+ </Button>
</div>
- <Button variant="org" isPending={isRegistering} onClick={handleAdd}>
- <PlusIcon /> Add
- </Button>
- </div>
- {isPending ? (
- <ContentLoader />
- ) : (
- <div className="flex flex-col gap-2">
- {credentials.length === 0 && (
- <p className="rounded-lg border border-border bg-container p-4 text-center text-sm text-muted">
- No passkeys registered yet.
- </p>
- )}
- {credentials.map((credential) => (
- <div
- key={credential.id}
- className="flex items-center justify-between rounded-lg border border-border bg-container p-3"
- >
- <div className="flex items-center gap-3">
- <FingerprintIcon className="text-muted" />
- <div>
- <p className="text-sm text-foreground">
- {credential.name || "Unnamed passkey"}
- </p>
- <p className="text-xs text-muted">
- Added {new Date(credential.createdAt).toLocaleDateString()}
- {credential.lastUsedAt &&
- ` · Last used ${new Date(credential.lastUsedAt).toLocaleDateString()}`}
- </p>
+ {isPending ? (
+ <ContentLoader />
+ ) : (
+ <div className="flex flex-col gap-2">
+ {credentials.length === 0 && (
+ <p className="rounded-lg border border-border bg-container p-4 text-center text-sm text-muted">
+ No passkeys registered yet.
+ </p>
+ )}
+ {credentials.map((credential) => (
+ <div
+ key={credential.id}
+ className="flex items-center justify-between rounded-lg border border-border bg-container p-3"
+ >
+ <div className="flex items-center gap-3">
+ <FingerprintIcon className="text-muted" />
+ <div>
+ <p className="text-sm text-foreground">
+ {credential.name || "Unnamed passkey"}
+ </p>
+ <p className="text-xs text-muted">
+ Added {new Date(credential.createdAt).toLocaleDateString()}
+ {credential.lastUsedAt &&
+ ` · Last used ${new Date(credential.lastUsedAt).toLocaleDateString()}`}
+ </p>
+ </div>
</div>
+ <Button
+ variant="danger"
+ size="sm"
+ onClick={() =>
+ setCredentialToRemove({
+ id: credential.id,
+ name: credential.name || "Unnamed passkey"
+ })
+ }
+ >
+ <TrashIcon /> Remove
+ </Button>
</div>
- <Button variant="danger" size="sm" onClick={() => handleDelete(credential.id)}>
- <TrashIcon /> Remove
- </Button>
- </div>
- ))}
- </div>
- )}
- </div>
- </SheetContent>
- </Sheet>
+ ))}
+ </div>
+ )}
+ </div>
+ </SheetContent>
+ </Sheet>
+
+ <AlertDialog
+ open={credentialToRemove !== null}
+ onOpenChange={(open) => !open && setCredentialToRemove(null)}
+ >
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Remove passkey?</AlertDialogTitle>
+ <AlertDialogDescription>
+ {`"${credentialToRemove?.name}" will no longer be usable as a second factor. You can register it again at any time.`}
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogAction variant="danger" isPending={isDeleting} onClick={handleDelete}>
+ Remove
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ </>
);
};
diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/RecoveryOptionsCard.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/RecoveryOptionsCard.tsx
index 8eea280e13..0c0a7643b3 100644
--- a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/RecoveryOptionsCard.tsx
+++ b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/RecoveryOptionsCard.tsx
@@ -46,7 +46,7 @@ export const RecoveryOptionsCard = () => {
};
return (
- <div className="rounded-lg border border-border bg-card p-4">
+ <div className="p-6">
<h3 className="mb-4 text-sm font-medium text-foreground">Recovery options</h3>
<div className="flex items-center justify-between gap-4">
<div className="flex items-start gap-3">