Files
zitadel/apps/login/src/app/(login)/[locale]/loginname/page.tsx

67 lines
2.0 KiB
TypeScript
Raw Normal View History

2024-09-26 22:50:55 -04:00
import { DynamicTheme } from "@/components/dynamic-theme";
import { SignInWithIdp } from "@/components/sign-in-with-idp";
import { UsernameForm } from "@/components/username-form";
2024-03-15 17:21:21 +01:00
import {
2024-04-01 10:00:31 +02:00
getBrandingSettings,
2024-03-15 17:21:21 +01:00
getLegalAndSupportSettings,
getLoginSettings,
settingsService,
2024-05-13 16:17:12 -04:00
} from "@/lib/zitadel";
2024-08-06 09:34:45 +02:00
import { makeReqCtx } from "@zitadel/client/v2";
2024-03-15 17:21:21 +01:00
function getIdentityProviders(orgId?: string) {
2024-03-15 17:21:21 +01:00
return settingsService
.getActiveIdentityProviders({ ctx: makeReqCtx(orgId) }, {})
.then((resp) => {
2024-03-15 17:21:21 +01:00
return resp.identityProviders;
});
}
export default async function Page({
searchParams,
}: {
searchParams: Record<string | number | symbol, string | undefined>;
}) {
const loginName = searchParams?.loginName;
const authRequestId = searchParams?.authRequestId;
2024-03-12 11:35:19 +01:00
const organization = searchParams?.organization;
const submit: boolean = searchParams?.submit === "true";
const loginSettings = await getLoginSettings(organization);
const legal = await getLegalAndSupportSettings();
2024-03-15 17:21:21 +01:00
const identityProviders = await getIdentityProviders(organization);
2024-03-15 17:21:21 +01:00
const host = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: "http://localhost:3000";
const branding = await getBrandingSettings(organization);
2023-06-29 19:06:30 +02:00
2024-04-01 10:00:31 +02:00
return (
<DynamicTheme branding={branding}>
<div className="flex flex-col items-center space-y-4">
<h1>Welcome back!</h1>
<p className="ztdl-p">Enter your login data.</p>
2024-03-15 17:21:21 +01:00
2024-04-01 10:00:31 +02:00
<UsernameForm
loginName={loginName}
2024-03-28 10:04:41 +01:00
authRequestId={authRequestId}
2024-04-01 10:00:31 +02:00
organization={organization}
submit={submit}
2024-07-17 16:54:25 +02:00
allowRegister={!!loginSettings?.allowRegister}
2024-08-08 10:29:17 +02:00
>
{legal && identityProviders && process.env.ZITADEL_API_URL && (
2024-09-26 22:50:55 -04:00
<SignInWithIdp
2024-08-08 10:29:17 +02:00
host={host}
identityProviders={identityProviders}
authRequestId={authRequestId}
organization={organization}
2024-09-26 22:50:55 -04:00
></SignInWithIdp>
2024-08-08 10:29:17 +02:00
)}
</UsernameForm>
2024-04-01 10:00:31 +02:00
</div>
</DynamicTheme>
2023-06-29 19:06:30 +02:00
);
2023-04-03 13:39:51 +02:00
}