From 430d87c1a17cad330394c6a6f51cfd9dee242673 Mon Sep 17 00:00:00 2001 From: peintnermax Date: Tue, 23 Apr 2024 11:26:34 +0200 Subject: [PATCH] state on mfa set --- apps/login/ui/ChooseSecondFactorToSetup.tsx | 85 +++++++++++++-------- apps/login/ui/StateBadge.tsx | 9 ++- 2 files changed, 61 insertions(+), 33 deletions(-) diff --git a/apps/login/ui/ChooseSecondFactorToSetup.tsx b/apps/login/ui/ChooseSecondFactorToSetup.tsx index d38e27d0923..5c5dd6471b3 100644 --- a/apps/login/ui/ChooseSecondFactorToSetup.tsx +++ b/apps/login/ui/ChooseSecondFactorToSetup.tsx @@ -4,6 +4,7 @@ import { AuthenticationMethodType, LoginSettings } from "@zitadel/server"; import Link from "next/link"; import { BadgeState, StateBadge } from "./StateBadge"; import clsx from "clsx"; +import { CheckIcon } from "@heroicons/react/24/outline"; type Props = { loginName?: string; @@ -24,8 +25,8 @@ export default function ChooseSecondFactorToSetup({ }: 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" + "relative 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 ? "" : "hover:shadow-lg hover:dark:bg-white/10" ); const TOTP = (alreadyAdded: boolean) => { @@ -34,7 +35,12 @@ export default function ChooseSecondFactorToSetup({ href={userMethods.includes(4) ? "" : "/otp/time-based/set"} className={cardClasses(alreadyAdded)} > -
+
{" "} Authenticator App - {alreadyAdded && ( - <> - - - - )}
+ {alreadyAdded && ( + <> + + + )} ); }; @@ -91,7 +96,12 @@ C72,238.87917,85.87916,225,102.99997,225H248z" const U2F = (alreadyAdded: boolean) => { return ( -
+
Universal Second Factor - {alreadyAdded && ( - <> - - - - )}
+ {alreadyAdded && ( + <> + + + )} ); }; @@ -121,7 +130,12 @@ C72,238.87917,85.87916,225,102.99997,225H248z" const EMAIL = (alreadyAdded: boolean) => { return ( -
+
Code via Email - {alreadyAdded && ( - <> - - - - )}
+ {alreadyAdded && ( + <> + + + )} ); }; @@ -152,7 +165,12 @@ C72,238.87917,85.87916,225,102.99997,225H248z" const SMS = (alreadyAdded: boolean) => { return ( -
+
Code via SMS - {alreadyAdded && ( - <> - - - - )}
+ {alreadyAdded && ( + <> + + + )} ); }; @@ -196,5 +213,11 @@ C72,238.87917,85.87916,225,102.99997,225H248z" } function Setup() { - return Setup; + return ( +
+ + + +
+ ); } diff --git a/apps/login/ui/StateBadge.tsx b/apps/login/ui/StateBadge.tsx index ff8605c7d5f..d5b862bfa82 100644 --- a/apps/login/ui/StateBadge.tsx +++ b/apps/login/ui/StateBadge.tsx @@ -11,9 +11,10 @@ export enum BadgeState { export type StateBadgeProps = { state: BadgeState; children: ReactNode; + evenPadding?: boolean; }; -const getBadgeClasses = (state: BadgeState) => +const getBadgeClasses = (state: BadgeState, evenPadding: boolean) => clsx({ "w-fit border-box h-18.5px flex flex-row items-center whitespace-nowrap tracking-wider leading-4 items-center justify-center px-2 py-2px text-12px rounded-full shadow-sm": true, @@ -25,11 +26,15 @@ const getBadgeClasses = (state: BadgeState) => state === BadgeState.Error, "bg-state-alert-light-background text-state-alert-light-color dark:bg-state-alert-dark-background dark:text-state-alert-dark-color": state === BadgeState.Alert, + "p-[2px]": evenPadding, }); export function StateBadge({ state = BadgeState.Success, + evenPadding = false, children, }: StateBadgeProps) { - return {children}; + return ( + {children} + ); }