Skip to content

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

1.2 KB
Raw Blame
import { MFA_METHOD_LABELS, VerifyStep } from "@app/components/mfa/setup";
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle
} from "@app/components/v3";
import { MfaMethod } from "@app/hooks/api/auth/types";

type Props = {
  method: MfaMethod | null;
  onOpenChange: (isOpen: boolean) => void;
  onCompleted: () => void;
};

// Lightweight single-method setup used from the enabled view (MFA is already on
// and recovery codes already exist, so no enable/recovery steps are needed).
export const MethodSetupDialog = ({ method, onOpenChange, onCompleted }: Props) => {
  return (
    <Dialog open={Boolean(method)} onOpenChange={onOpenChange}>
      <DialogContent className="sm:max-w-lg">
        <DialogHeader>
          <DialogTitle>
            {method ? `Set up ${MFA_METHOD_LABELS[method]}` : "Set up method"}
          </DialogTitle>
          <DialogDescription>Configure this method as a second factor.</DialogDescription>
        </DialogHeader>
        {method && (
          <VerifyStep
            method={method}
            variant="neutral"
            onVerified={() => {
              onCompleted();
              onOpenChange(false);
            }}
          />
        )}
      </DialogContent>
    </Dialog>
  );
};