2024-04-16 09:32:56 +02:00
|
|
|
import {
|
|
|
|
|
getBrandingSettings,
|
|
|
|
|
getLoginSettings,
|
2024-08-08 15:47:18 +02:00
|
|
|
sessionService,
|
2024-05-13 16:17:12 -04:00
|
|
|
} from "@/lib/zitadel";
|
|
|
|
|
import Alert from "@/ui/Alert";
|
|
|
|
|
import DynamicTheme from "@/ui/DynamicTheme";
|
|
|
|
|
import PasswordForm from "@/ui/PasswordForm";
|
|
|
|
|
import UserAvatar from "@/ui/UserAvatar";
|
2024-08-07 15:53:55 +02:00
|
|
|
import { loadMostRecentSession } from "@zitadel/next";
|
2023-04-03 13:39:51 +02:00
|
|
|
|
2023-05-24 14:28:55 +02:00
|
|
|
export default async function Page({
|
|
|
|
|
searchParams,
|
|
|
|
|
}: {
|
|
|
|
|
searchParams: Record<string | number | symbol, string | undefined>;
|
|
|
|
|
}) {
|
2024-03-25 13:39:23 +01:00
|
|
|
const { loginName, organization, promptPasswordless, authRequestId, alt } =
|
|
|
|
|
searchParams;
|
2023-04-03 13:39:51 +02:00
|
|
|
|
2024-08-08 15:47:18 +02:00
|
|
|
const sessionFactors = await loadMostRecentSession(sessionService, {
|
|
|
|
|
loginName,
|
|
|
|
|
organization,
|
|
|
|
|
});
|
2023-05-22 16:28:47 +02:00
|
|
|
|
2024-04-07 03:56:46 -04:00
|
|
|
const branding = await getBrandingSettings(organization);
|
|
|
|
|
const loginSettings = await getLoginSettings(organization);
|
2024-04-01 10:00:31 +02:00
|
|
|
|
2023-04-03 13:39:51 +02:00
|
|
|
return (
|
2024-04-01 10:00:31 +02:00
|
|
|
<DynamicTheme branding={branding}>
|
|
|
|
|
<div className="flex flex-col items-center space-y-4">
|
|
|
|
|
<h1>{sessionFactors?.factors?.user?.displayName ?? "Password"}</h1>
|
|
|
|
|
<p className="ztdl-p mb-6 block">Enter your password.</p>
|
|
|
|
|
|
|
|
|
|
{!sessionFactors && (
|
|
|
|
|
<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>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{sessionFactors && (
|
|
|
|
|
<UserAvatar
|
|
|
|
|
loginName={loginName ?? sessionFactors.factors?.user?.loginName}
|
|
|
|
|
displayName={sessionFactors.factors?.user?.displayName}
|
|
|
|
|
showDropdown
|
2024-05-03 10:09:18 +02:00
|
|
|
searchParams={searchParams}
|
2024-04-01 10:00:31 +02:00
|
|
|
></UserAvatar>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<PasswordForm
|
|
|
|
|
loginName={loginName}
|
|
|
|
|
authRequestId={authRequestId}
|
|
|
|
|
organization={organization}
|
2024-04-16 09:32:56 +02:00
|
|
|
loginSettings={loginSettings}
|
2024-04-01 10:00:31 +02:00
|
|
|
promptPasswordless={promptPasswordless === "true"}
|
|
|
|
|
isAlternative={alt === "true"}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</DynamicTheme>
|
2023-04-03 13:39:51 +02:00
|
|
|
);
|
|
|
|
|
}
|