mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-13 15:02:11 +00:00
69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
import { Alert } from "@/components/alert";
|
|
import { DynamicTheme } from "@/components/dynamic-theme";
|
|
import { LoginPasskey } from "@/components/login-passkey";
|
|
import { UserAvatar } from "@/components/user-avatar";
|
|
import { getSessionCookieById } from "@/lib/cookies";
|
|
import { loadMostRecentSession } from "@/lib/session";
|
|
import { getBrandingSettings, getSession } from "@/lib/zitadel";
|
|
|
|
export default async function Page({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Record<string | number | symbol, string | undefined>;
|
|
}) {
|
|
const { loginName, authRequestId, sessionId, organization } = searchParams;
|
|
|
|
const branding = await getBrandingSettings(organization);
|
|
|
|
const sessionFactors = sessionId
|
|
? await loadSessionById(sessionId, organization)
|
|
: await loadMostRecentSession({ loginName, organization });
|
|
|
|
async function loadSessionById(sessionId: string, organization?: string) {
|
|
const recent = await getSessionCookieById({ sessionId, organization });
|
|
return getSession({
|
|
sessionId: recent.id,
|
|
sessionToken: recent.token,
|
|
}).then((response) => {
|
|
if (response?.session) {
|
|
return response.session;
|
|
}
|
|
});
|
|
}
|
|
|
|
return (
|
|
<DynamicTheme branding={branding}>
|
|
<div className="flex flex-col items-center space-y-4">
|
|
<h1>Verify 2-Factor</h1>
|
|
|
|
{sessionFactors && (
|
|
<UserAvatar
|
|
loginName={loginName ?? sessionFactors.factors?.user?.loginName}
|
|
displayName={sessionFactors.factors?.user?.displayName}
|
|
showDropdown
|
|
searchParams={searchParams}
|
|
></UserAvatar>
|
|
)}
|
|
<p className="ztdl-p mb-6 block">
|
|
Verify your account with your device.
|
|
</p>
|
|
|
|
{!(loginName || sessionId) && (
|
|
<Alert>Provide your active session as loginName param</Alert>
|
|
)}
|
|
|
|
{(loginName || sessionId) && (
|
|
<LoginPasskey
|
|
loginName={loginName}
|
|
sessionId={sessionId}
|
|
authRequestId={authRequestId}
|
|
altPassword={false}
|
|
organization={organization}
|
|
login={false} // this sets the userVerificationRequirement to discouraged as its used as second factor
|
|
/>
|
|
)}
|
|
</div>
|
|
</DynamicTheme>
|
|
);
|
|
}
|