diff --git a/apps/login/src/app/(login)/otp/[method]/page.tsx b/apps/login/src/app/(login)/otp/[method]/page.tsx index e25c30af81a..965d6af0207 100644 --- a/apps/login/src/app/(login)/otp/[method]/page.tsx +++ b/apps/login/src/app/(login)/otp/[method]/page.tsx @@ -1,4 +1,4 @@ -import { getBrandingSettings } from "@/lib/zitadel"; +import { getBrandingSettings, sessionService } from "@/lib/zitadel"; import Alert from "@/ui/Alert"; import DynamicTheme from "@/ui/DynamicTheme"; import LoginOTP from "@/ui/LoginOTP"; @@ -17,7 +17,10 @@ export default async function Page({ const { method } = params; - const session = await loadMostRecentSession(loginName, organization); + const session = await loadMostRecentSession(sessionService, { + loginName, + organization, + }); const branding = await getBrandingSettings(organization); diff --git a/apps/login/src/app/(login)/otp/[method]/set/page.tsx b/apps/login/src/app/(login)/otp/[method]/set/page.tsx index 740f758b973..dbd0afa8b06 100644 --- a/apps/login/src/app/(login)/otp/[method]/set/page.tsx +++ b/apps/login/src/app/(login)/otp/[method]/set/page.tsx @@ -3,6 +3,7 @@ import { addOTPSMS, getBrandingSettings, registerTOTP, + sessionService, } from "@/lib/zitadel"; import Alert from "@/ui/Alert"; import BackButton from "@/ui/BackButton"; @@ -26,7 +27,10 @@ export default async function Page({ const { method } = params; const branding = await getBrandingSettings(organization); - const session = await loadMostRecentSession(loginName, organization); + const session = await loadMostRecentSession(sessionService, { + loginName, + organization, + }); let totpResponse: RegisterTOTPResponse | undefined, totpError: Error | undefined; diff --git a/apps/login/src/app/(login)/passkey/add/page.tsx b/apps/login/src/app/(login)/passkey/add/page.tsx index 59b63020aa5..6cad45b718e 100644 --- a/apps/login/src/app/(login)/passkey/add/page.tsx +++ b/apps/login/src/app/(login)/passkey/add/page.tsx @@ -1,4 +1,4 @@ -import { getBrandingSettings, getSession } from "@/lib/zitadel"; +import { getBrandingSettings, getSession, sessionService } from "@/lib/zitadel"; import Alert, { AlertType } from "@/ui/Alert"; import DynamicTheme from "@/ui/DynamicTheme"; import RegisterPasskey from "@/ui/RegisterPasskey"; @@ -13,7 +13,10 @@ export default async function Page({ const { loginName, promptPasswordless, organization, authRequestId } = searchParams; - const sessionFactors = await loadMostRecentSession(loginName, organization); + const sessionFactors = await loadMostRecentSession(sessionService, { + loginName, + organization, + }); const title = !!promptPasswordless ? "Authenticate with a passkey" diff --git a/apps/login/src/app/(login)/password/page.tsx b/apps/login/src/app/(login)/password/page.tsx index 9927fda97a1..a4107a0f3f8 100644 --- a/apps/login/src/app/(login)/password/page.tsx +++ b/apps/login/src/app/(login)/password/page.tsx @@ -2,6 +2,7 @@ import { getBrandingSettings, getLoginSettings, getSession, + sessionService, } from "@/lib/zitadel"; import Alert from "@/ui/Alert"; import DynamicTheme from "@/ui/DynamicTheme"; @@ -17,7 +18,10 @@ export default async function Page({ const { loginName, organization, promptPasswordless, authRequestId, alt } = searchParams; - const sessionFactors = await loadMostRecentSession(loginName, organization); + const sessionFactors = await loadMostRecentSession(sessionService, { + loginName, + organization, + }); const branding = await getBrandingSettings(organization); const loginSettings = await getLoginSettings(organization); diff --git a/apps/login/src/app/(login)/u2f/set/page.tsx b/apps/login/src/app/(login)/u2f/set/page.tsx index 5834c7828c7..7ffab6e2885 100644 --- a/apps/login/src/app/(login)/u2f/set/page.tsx +++ b/apps/login/src/app/(login)/u2f/set/page.tsx @@ -1,4 +1,4 @@ -import { getBrandingSettings, getSession } from "@/lib/zitadel"; +import { getBrandingSettings, getSession, sessionService } from "@/lib/zitadel"; import Alert, { AlertType } from "@/ui/Alert"; import DynamicTheme from "@/ui/DynamicTheme"; import RegisterPasskey from "@/ui/RegisterPasskey"; @@ -14,7 +14,10 @@ export default async function Page({ }) { const { loginName, organization, authRequestId } = searchParams; - const sessionFactors = await loadMostRecentSession(loginName, organization); + const sessionFactors = await loadMostRecentSession(sessionService, { + loginName, + organization, + }); const title = "Use your passkey to confirm it's really you"; const description = diff --git a/packages/zitadel-next/src/utils/session.ts b/packages/zitadel-next/src/utils/session.ts index fac865fffc9..32829477aa1 100644 --- a/packages/zitadel-next/src/utils/session.ts +++ b/packages/zitadel-next/src/utils/session.ts @@ -4,10 +4,12 @@ import { getMostRecentCookieWithLoginname } from "./cookies"; export async function loadMostRecentSession( sessionService: any, // TODO: SessionServiceClient, - loginName?: string, - organization?: string, + sessionParams: { loginName?: string; organization?: string }, ): Promise { - const recent = await getMostRecentCookieWithLoginname({ loginName, organization }); + const recent = await getMostRecentCookieWithLoginname({ + loginName: sessionParams.loginName, + organization: sessionParams.organization, + }); return sessionService .getSession({ sessionId: recent.id, sessionToken: recent.token }, {}) .then((resp: GetSessionResponse) => resp.session);