mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-13 15:12:47 +00:00
79 lines
2.1 KiB
TypeScript
79 lines
2.1 KiB
TypeScript
import { Alert } from "@/components/alert";
|
|
import { ChangePasswordForm } from "@/components/change-password-form";
|
|
import { DynamicTheme } from "@/components/dynamic-theme";
|
|
import { UserAvatar } from "@/components/user-avatar";
|
|
import { getSessionCookieById } from "@/lib/cookies";
|
|
import {
|
|
getBrandingSettings,
|
|
getPasswordComplexitySettings,
|
|
getSession,
|
|
} from "@/lib/zitadel";
|
|
|
|
export default async function Page({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Record<string | number | symbol, string | undefined>;
|
|
}) {
|
|
const { sessionId } = searchParams;
|
|
|
|
if (!sessionId) {
|
|
return (
|
|
<div>
|
|
<h1>Session ID not found</h1>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const sessionCookie = await getSessionCookieById({
|
|
sessionId,
|
|
});
|
|
|
|
const { session } = await getSession({
|
|
sessionId: sessionCookie.id,
|
|
sessionToken: sessionCookie.token,
|
|
});
|
|
|
|
const passwordComplexitySettings = await getPasswordComplexitySettings(
|
|
session?.factors?.user?.organizationId,
|
|
);
|
|
|
|
const branding = await getBrandingSettings(
|
|
session?.factors?.user?.organizationId,
|
|
);
|
|
|
|
return (
|
|
<DynamicTheme branding={branding}>
|
|
<div className="flex flex-col items-center space-y-4">
|
|
<h1>Set Password</h1>
|
|
<p className="ztdl-p">Set the password for your account</p>
|
|
|
|
{!session && (
|
|
<div className="py-4">
|
|
<Alert>
|
|
Could not get the context of the user. Make sure to enter the
|
|
username first or provide a loginName as searchParam.
|
|
</Alert>
|
|
</div>
|
|
)}
|
|
|
|
{session && (
|
|
<UserAvatar
|
|
loginName={session.factors?.user?.loginName}
|
|
displayName={session.factors?.user?.displayName}
|
|
showDropdown
|
|
searchParams={searchParams}
|
|
></UserAvatar>
|
|
)}
|
|
|
|
{passwordComplexitySettings && session?.factors?.user?.id && (
|
|
<ChangePasswordForm
|
|
passwordComplexitySettings={passwordComplexitySettings}
|
|
userId={session.factors.user.id}
|
|
sessionId={sessionId}
|
|
></ChangePasswordForm>
|
|
)}
|
|
</div>
|
|
</DynamicTheme>
|
|
);
|
|
}
|