mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 14:32:34 +00:00
account selection with params
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import { getBrandingSettings, getLoginSettings, server } from "#/lib/zitadel";
|
||||
import {
|
||||
getBrandingSettings,
|
||||
getLoginSettings,
|
||||
getSession,
|
||||
server,
|
||||
} from "#/lib/zitadel";
|
||||
import Alert from "#/ui/Alert";
|
||||
import DynamicTheme from "#/ui/DynamicTheme";
|
||||
import LoginOTP from "#/ui/LoginOTP";
|
||||
import UserAvatar from "#/ui/UserAvatar";
|
||||
import { getMostRecentCookieWithLoginname } from "#/utils/cookies";
|
||||
|
||||
export default async function Page({
|
||||
searchParams,
|
||||
@@ -14,8 +22,21 @@ export default async function Page({
|
||||
|
||||
const { method } = params;
|
||||
|
||||
const { session, token } = await loadSession(loginName, organization);
|
||||
|
||||
const branding = await getBrandingSettings(server, organization);
|
||||
|
||||
async function loadSession(loginName?: string, organization?: string) {
|
||||
const recent = await getMostRecentCookieWithLoginname(
|
||||
loginName,
|
||||
organization
|
||||
);
|
||||
|
||||
return getSession(server, recent.id, recent.token).then((response) => {
|
||||
return { session: response?.session, token: recent.token };
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<DynamicTheme branding={branding}>
|
||||
<div className="flex flex-col items-center space-y-4">
|
||||
@@ -30,6 +51,24 @@ export default async function Page({
|
||||
<p className="ztdl-p">Enter the code you got via your email.</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={loginName ?? session.factors?.user?.loginName}
|
||||
displayName={session.factors?.user?.displayName}
|
||||
showDropdown
|
||||
searchParams={searchParams}
|
||||
></UserAvatar>
|
||||
)}
|
||||
|
||||
{method && (
|
||||
<LoginOTP
|
||||
loginName={loginName}
|
||||
|
||||
@@ -121,6 +121,7 @@ export default async function Page({
|
||||
loginName={loginName ?? session.factors?.user?.loginName}
|
||||
displayName={session.factors?.user?.displayName}
|
||||
showDropdown
|
||||
searchParams={searchParams}
|
||||
></UserAvatar>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user