From ec20bb48f74658f7b80b2a1f57277cd491cbcb0b Mon Sep 17 00:00:00 2001 From: peintnermax Date: Mon, 29 Apr 2024 15:43:57 +0200 Subject: [PATCH] set context in url for method --- apps/login/app/(login)/u2f/set/page.tsx | 24 ++------------ apps/login/ui/ChooseSecondFactorToSetup.tsx | 35 ++++++++++++++++++--- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/apps/login/app/(login)/u2f/set/page.tsx b/apps/login/app/(login)/u2f/set/page.tsx index c3b498dfb78..a5c8fe52a83 100644 --- a/apps/login/app/(login)/u2f/set/page.tsx +++ b/apps/login/app/(login)/u2f/set/page.tsx @@ -1,13 +1,5 @@ -import { - addOTPEmail, - addOTPSMS, - getBrandingSettings, - getSession, - registerTOTP, - server, -} from "#/lib/zitadel"; +import { getBrandingSettings, getSession, server } from "#/lib/zitadel"; import DynamicTheme from "#/ui/DynamicTheme"; -import TOTPRegister from "#/ui/TOTPRegister"; import { getMostRecentCookieWithLoginname } from "#/utils/cookies"; export default async function Page({ @@ -21,7 +13,7 @@ export default async function Page({ const branding = await getBrandingSettings(server, organization); - const totpResponse = await loadSession(loginName, organization).then(); + const session = await loadSession(loginName, organization); async function loadSession(loginName?: string, organization?: string) { const recent = await getMostRecentCookieWithLoginname( @@ -41,18 +33,6 @@ export default async function Page({

Choose a device to register for 2-Factor Authentication.

- -
- {/* {auth &&
{auth.to}
} */} - {totpResponse && - "uri" in totpResponse && - "secret" in totpResponse && ( - - )} -
); diff --git a/apps/login/ui/ChooseSecondFactorToSetup.tsx b/apps/login/ui/ChooseSecondFactorToSetup.tsx index 5c5dd6471b3..d17675e86db 100644 --- a/apps/login/ui/ChooseSecondFactorToSetup.tsx +++ b/apps/login/ui/ChooseSecondFactorToSetup.tsx @@ -1,6 +1,10 @@ "use client"; -import { AuthenticationMethodType, LoginSettings } from "@zitadel/server"; +import { + AuthenticationMethodType, + LoginSettings, + login, +} from "@zitadel/server"; import Link from "next/link"; import { BadgeState, StateBadge } from "./StateBadge"; import clsx from "clsx"; @@ -29,10 +33,25 @@ export default function ChooseSecondFactorToSetup({ alreadyAdded ? "" : "hover:shadow-lg hover:dark:bg-white/10" ); + const params = new URLSearchParams({}); + + if (loginName) { + params.append("loginName", loginName); + } + if (sessionId) { + params.append("sessionId", sessionId); + } + if (authRequestId) { + params.append("authRequestId", authRequestId); + } + if (organization) { + params.append("organization", organization); + } + const TOTP = (alreadyAdded: boolean) => { return (
{ return ( - +
{ return ( - +
{ return ( - +