Files
zitadel/apps/login/src/app/(login)/register/page.tsx

79 lines
2.3 KiB
TypeScript
Raw Normal View History

2024-09-26 22:50:55 -04:00
import { DynamicTheme } from "@/components/dynamic-theme";
2024-11-21 14:12:13 +01:00
import { RegisterForm } from "@/components/register-form";
2023-04-26 15:14:28 +02:00
import {
getBrandingSettings,
2024-10-18 15:42:38 +02:00
getDefaultOrg,
2023-05-15 09:23:59 +02:00
getLegalAndSupportSettings,
getLoginSettings,
2023-05-15 09:23:59 +02:00
getPasswordComplexitySettings,
2024-05-13 16:17:12 -04:00
} from "@/lib/zitadel";
2024-10-28 14:52:26 +01:00
import { Organization } from "@zitadel/proto/zitadel/org/v2/org_pb";
2024-10-10 16:15:10 +02:00
import { getLocale, getTranslations } from "next-intl/server";
2025-01-15 09:57:24 +01:00
import { headers } from "next/headers";
2024-11-22 11:27:37 +01:00
export default async function Page(props: {
searchParams: Promise<Record<string | number | symbol, string | undefined>>;
}) {
2024-11-22 11:25:03 +01:00
const searchParams = await props.searchParams;
2024-10-10 16:15:10 +02:00
const locale = getLocale();
const t = await getTranslations({ locale, namespace: "register" });
2024-10-18 15:42:38 +02:00
let { firstname, lastname, email, organization, authRequestId } =
searchParams;
2025-01-15 09:57:24 +01:00
const host = (await headers()).get("host");
if (!host || typeof host !== "string") {
throw new Error("No host found");
}
if (!organization) {
2025-01-15 09:57:24 +01:00
const org: Organization | null = await getDefaultOrg({ host });
2024-11-12 16:54:42 +01:00
if (org) {
2024-10-28 15:06:45 +01:00
organization = org.id;
2024-10-18 15:42:38 +02:00
}
}
2025-01-15 09:57:24 +01:00
const legal = await getLegalAndSupportSettings({ host, organization });
const passwordComplexitySettings = await getPasswordComplexitySettings({
host,
organization,
});
2023-04-03 13:39:51 +02:00
2025-01-15 09:57:24 +01:00
const branding = await getBrandingSettings({ host, organization });
2025-01-15 09:57:24 +01:00
const loginSettings = await getLoginSettings({ host, organization });
if (!loginSettings?.allowRegister) {
return (
<DynamicTheme branding={branding}>
2024-11-22 11:25:03 +01:00
<div className="flex flex-col items-center space-y-4">
<h1>{t("disabled.title")}</h1>
<p className="ztdl-p">{t("disabled.description")}</p>
</div>
</DynamicTheme>
);
}
return (
<DynamicTheme branding={branding}>
<div className="flex flex-col items-center space-y-4">
2024-10-10 16:15:10 +02:00
<h1>{t("title")}</h1>
<p className="ztdl-p">{t("description")}</p>
2023-04-03 13:39:51 +02:00
{legal && passwordComplexitySettings && (
2024-11-21 14:12:13 +01:00
<RegisterForm
legal={legal}
organization={organization}
firstname={firstname}
lastname={lastname}
email={email}
authRequestId={authRequestId}
loginSettings={loginSettings}
2024-11-21 14:12:13 +01:00
></RegisterForm>
)}
</div>
</DynamicTheme>
2023-04-03 13:39:51 +02:00
);
}