function def

This commit is contained in:
peintnermax
2024-08-08 15:47:18 +02:00
parent 25313db4a8
commit 58cde933c8
6 changed files with 30 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
import { getBrandingSettings } from "@/lib/zitadel"; import { getBrandingSettings, sessionService } from "@/lib/zitadel";
import Alert from "@/ui/Alert"; import Alert from "@/ui/Alert";
import DynamicTheme from "@/ui/DynamicTheme"; import DynamicTheme from "@/ui/DynamicTheme";
import LoginOTP from "@/ui/LoginOTP"; import LoginOTP from "@/ui/LoginOTP";
@@ -17,7 +17,10 @@ export default async function Page({
const { method } = params; const { method } = params;
const session = await loadMostRecentSession(loginName, organization); const session = await loadMostRecentSession(sessionService, {
loginName,
organization,
});
const branding = await getBrandingSettings(organization); const branding = await getBrandingSettings(organization);

View File

@@ -3,6 +3,7 @@ import {
addOTPSMS, addOTPSMS,
getBrandingSettings, getBrandingSettings,
registerTOTP, registerTOTP,
sessionService,
} from "@/lib/zitadel"; } from "@/lib/zitadel";
import Alert from "@/ui/Alert"; import Alert from "@/ui/Alert";
import BackButton from "@/ui/BackButton"; import BackButton from "@/ui/BackButton";
@@ -26,7 +27,10 @@ export default async function Page({
const { method } = params; const { method } = params;
const branding = await getBrandingSettings(organization); const branding = await getBrandingSettings(organization);
const session = await loadMostRecentSession(loginName, organization); const session = await loadMostRecentSession(sessionService, {
loginName,
organization,
});
let totpResponse: RegisterTOTPResponse | undefined, let totpResponse: RegisterTOTPResponse | undefined,
totpError: Error | undefined; totpError: Error | undefined;

View File

@@ -1,4 +1,4 @@
import { getBrandingSettings, getSession } from "@/lib/zitadel"; import { getBrandingSettings, getSession, sessionService } from "@/lib/zitadel";
import Alert, { AlertType } from "@/ui/Alert"; import Alert, { AlertType } from "@/ui/Alert";
import DynamicTheme from "@/ui/DynamicTheme"; import DynamicTheme from "@/ui/DynamicTheme";
import RegisterPasskey from "@/ui/RegisterPasskey"; import RegisterPasskey from "@/ui/RegisterPasskey";
@@ -13,7 +13,10 @@ export default async function Page({
const { loginName, promptPasswordless, organization, authRequestId } = const { loginName, promptPasswordless, organization, authRequestId } =
searchParams; searchParams;
const sessionFactors = await loadMostRecentSession(loginName, organization); const sessionFactors = await loadMostRecentSession(sessionService, {
loginName,
organization,
});
const title = !!promptPasswordless const title = !!promptPasswordless
? "Authenticate with a passkey" ? "Authenticate with a passkey"

View File

@@ -2,6 +2,7 @@ import {
getBrandingSettings, getBrandingSettings,
getLoginSettings, getLoginSettings,
getSession, getSession,
sessionService,
} from "@/lib/zitadel"; } from "@/lib/zitadel";
import Alert from "@/ui/Alert"; import Alert from "@/ui/Alert";
import DynamicTheme from "@/ui/DynamicTheme"; import DynamicTheme from "@/ui/DynamicTheme";
@@ -17,7 +18,10 @@ export default async function Page({
const { loginName, organization, promptPasswordless, authRequestId, alt } = const { loginName, organization, promptPasswordless, authRequestId, alt } =
searchParams; searchParams;
const sessionFactors = await loadMostRecentSession(loginName, organization); const sessionFactors = await loadMostRecentSession(sessionService, {
loginName,
organization,
});
const branding = await getBrandingSettings(organization); const branding = await getBrandingSettings(organization);
const loginSettings = await getLoginSettings(organization); const loginSettings = await getLoginSettings(organization);

View File

@@ -1,4 +1,4 @@
import { getBrandingSettings, getSession } from "@/lib/zitadel"; import { getBrandingSettings, getSession, sessionService } from "@/lib/zitadel";
import Alert, { AlertType } from "@/ui/Alert"; import Alert, { AlertType } from "@/ui/Alert";
import DynamicTheme from "@/ui/DynamicTheme"; import DynamicTheme from "@/ui/DynamicTheme";
import RegisterPasskey from "@/ui/RegisterPasskey"; import RegisterPasskey from "@/ui/RegisterPasskey";
@@ -14,7 +14,10 @@ export default async function Page({
}) { }) {
const { loginName, organization, authRequestId } = searchParams; 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 title = "Use your passkey to confirm it's really you";
const description = const description =

View File

@@ -4,10 +4,12 @@ import { getMostRecentCookieWithLoginname } from "./cookies";
export async function loadMostRecentSession( export async function loadMostRecentSession(
sessionService: any, // TODO: SessionServiceClient, sessionService: any, // TODO: SessionServiceClient,
loginName?: string, sessionParams: { loginName?: string; organization?: string },
organization?: string,
): Promise<Session | undefined> { ): Promise<Session | undefined> {
const recent = await getMostRecentCookieWithLoginname({ loginName, organization }); const recent = await getMostRecentCookieWithLoginname({
loginName: sessionParams.loginName,
organization: sessionParams.organization,
});
return sessionService return sessionService
.getSession({ sessionId: recent.id, sessionToken: recent.token }, {}) .getSession({ sessionId: recent.id, sessionToken: recent.token }, {})
.then((resp: GetSessionResponse) => resp.session); .then((resp: GetSessionResponse) => resp.session);