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,
|
|
|
|
|
server,
|
2024-05-13 16:17:12 -04:00
|
|
|
} from "@/lib/zitadel";
|
|
|
|
|
import DynamicTheme from "@/ui/DynamicTheme";
|
|
|
|
|
import { SignInWithIDP } from "@/ui/SignInWithIDP";
|
|
|
|
|
import UsernameForm from "@/ui/UsernameForm";
|
2024-03-15 17:21:21 +01:00
|
|
|
import {
|
|
|
|
|
GetActiveIdentityProvidersResponse,
|
|
|
|
|
IdentityProvider,
|
|
|
|
|
ZitadelServer,
|
|
|
|
|
settings,
|
|
|
|
|
} from "@zitadel/server";
|
|
|
|
|
|
|
|
|
|
function getIdentityProviders(
|
|
|
|
|
server: ZitadelServer,
|
2024-05-13 16:17:12 -04:00
|
|
|
orgId?: string,
|
2024-03-15 17:21:21 +01:00
|
|
|
): Promise<IdentityProvider[] | undefined> {
|
|
|
|
|
const settingsService = settings.getSettings(server);
|
|
|
|
|
return settingsService
|
|
|
|
|
.getActiveIdentityProviders(
|
|
|
|
|
orgId ? { ctx: { orgId } } : { ctx: { instance: true } },
|
2024-05-13 16:17:12 -04:00
|
|
|
{},
|
2024-03-15 17:21:21 +01:00
|
|
|
)
|
|
|
|
|
.then((resp: GetActiveIdentityProvidersResponse) => {
|
|
|
|
|
return resp.identityProviders;
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-06-29 14:54:07 +02:00
|
|
|
|
|
|
|
|
export default async function Page({
|
|
|
|
|
searchParams,
|
|
|
|
|
}: {
|
|
|
|
|
searchParams: Record<string | number | symbol, string | undefined>;
|
|
|
|
|
}) {
|
|
|
|
|
const loginName = searchParams?.loginName;
|
2023-08-21 15:14:12 +02:00
|
|
|
const authRequestId = searchParams?.authRequestId;
|
2024-03-12 11:35:19 +01:00
|
|
|
const organization = searchParams?.organization;
|
2023-07-03 17:05:55 +02:00
|
|
|
const submit: boolean = searchParams?.submit === "true";
|
2023-06-29 14:54:07 +02:00
|
|
|
|
2024-03-12 11:35:19 +01:00
|
|
|
const loginSettings = await getLoginSettings(server, organization);
|
2024-03-15 17:21:21 +01:00
|
|
|
const legal = await getLegalAndSupportSettings(server);
|
|
|
|
|
|
2024-03-25 13:39:23 +01:00
|
|
|
const identityProviders = await getIdentityProviders(server, organization);
|
2024-03-15 17:21:21 +01:00
|
|
|
|
|
|
|
|
const host = process.env.VERCEL_URL
|
|
|
|
|
? `https://${process.env.VERCEL_URL}`
|
|
|
|
|
: "http://localhost:3000";
|
2023-06-29 14:54:07 +02:00
|
|
|
|
2024-04-01 10:00:31 +02:00
|
|
|
const branding = await getBrandingSettings(server, 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
|
|
|
|
|
loginSettings={loginSettings}
|
|
|
|
|
loginName={loginName}
|
2024-03-28 10:04:41 +01:00
|
|
|
authRequestId={authRequestId}
|
2024-04-01 10:00:31 +02:00
|
|
|
organization={organization}
|
|
|
|
|
submit={submit}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{legal && identityProviders && process.env.ZITADEL_API_URL && (
|
|
|
|
|
<SignInWithIDP
|
|
|
|
|
host={host}
|
|
|
|
|
identityProviders={identityProviders}
|
|
|
|
|
authRequestId={authRequestId}
|
2024-04-01 13:57:39 +02:00
|
|
|
organization={organization}
|
2024-04-01 10:00:31 +02:00
|
|
|
></SignInWithIDP>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</DynamicTheme>
|
2023-06-29 19:06:30 +02:00
|
|
|
);
|
2023-04-03 13:39:51 +02:00
|
|
|
}
|