"use client"; import { AuthenticationMethodType, LoginSettings } from "@zitadel/server"; import Link from "next/link"; import { BadgeState, StateBadge } from "./StateBadge"; import clsx from "clsx"; type Props = { loginName?: string; sessionId?: string; authRequestId?: string; organization?: string; loginSettings: LoginSettings; userMethods: AuthenticationMethodType[]; }; export default function ChooseSecondFactorToSetup({ loginName, sessionId, authRequestId, organization, loginSettings, userMethods, }: Props) { const cardClasses = (alreadyAdded: boolean) => clsx( "bg-background-light-400 dark:bg-background-dark-400 group block space-y-1.5 rounded-md px-5 py-3 border border-divider-light dark:border-divider-dark transition-all ", alreadyAdded ? "opacity-50" : "hover:shadow-lg hover:dark:bg-white/10" ); const TOTP = (alreadyAdded: boolean) => { return (
{" "} Authenticator App {alreadyAdded && ( <> )}
); }; const U2F = (alreadyAdded: boolean) => { return (
Universal Second Factor {alreadyAdded && ( <> )}
); }; const EMAIL = (alreadyAdded: boolean) => { return (
Code via Email {alreadyAdded && ( <> )}
); }; const SMS = (alreadyAdded: boolean) => { return (
Code via SMS {alreadyAdded && ( <> )}
); }; return (
{loginSettings.secondFactors.map((factor, i) => { return (
{factor === 1 && TOTP(userMethods.includes(4))} {factor === 2 && U2F(userMethods.includes(5))} {factor === 3 && EMAIL(userMethods.includes(7))} {factor === 4 && SMS(userMethods.includes(6))}
); })}
); } function Setup() { return Setup; }