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";
|
2025-01-29 10:44:26 +01:00
|
|
|
import { getServiceUrlFromHeaders } from "@/lib/service";
|
2023-04-26 15:14:28 +02:00
|
|
|
import {
|
2024-04-01 13:57:39 +02:00
|
|
|
getBrandingSettings,
|
2024-10-18 15:42:38 +02:00
|
|
|
getDefaultOrg,
|
2023-05-15 09:23:59 +02:00
|
|
|
getLegalAndSupportSettings,
|
2024-11-19 15:57:40 +01:00
|
|
|
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";
|
2023-06-16 13:57:29 +02:00
|
|
|
|
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 } =
|
2024-03-25 15:18:51 +01:00
|
|
|
searchParams;
|
2023-06-16 13:57:29 +02:00
|
|
|
|
2025-01-28 09:47:35 +01:00
|
|
|
const _headers = await headers();
|
2025-01-29 15:47:31 +01:00
|
|
|
const { serviceUrl, serviceRegion } = getServiceUrlFromHeaders(_headers);
|
2025-01-15 09:57:24 +01:00
|
|
|
|
2024-09-13 14:01:03 +02:00
|
|
|
if (!organization) {
|
2025-01-29 16:00:21 +01:00
|
|
|
const org: Organization | null = await getDefaultOrg({
|
|
|
|
|
serviceUrl,
|
|
|
|
|
serviceRegion,
|
|
|
|
|
});
|
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
|
|
|
}
|
2024-09-13 14:01:03 +02:00
|
|
|
}
|
|
|
|
|
|
2025-01-29 16:00:21 +01:00
|
|
|
const legal = await getLegalAndSupportSettings({
|
|
|
|
|
serviceUrl,
|
|
|
|
|
serviceRegion,
|
|
|
|
|
organization,
|
|
|
|
|
});
|
2025-01-15 09:57:24 +01:00
|
|
|
const passwordComplexitySettings = await getPasswordComplexitySettings({
|
2025-01-29 10:34:33 +01:00
|
|
|
serviceUrl,
|
2025-01-29 16:00:21 +01:00
|
|
|
serviceRegion,
|
2025-01-15 09:57:24 +01:00
|
|
|
organization,
|
|
|
|
|
});
|
2023-04-03 13:39:51 +02:00
|
|
|
|
2025-01-29 16:00:21 +01:00
|
|
|
const branding = await getBrandingSettings({
|
|
|
|
|
serviceUrl,
|
|
|
|
|
serviceRegion,
|
|
|
|
|
organization,
|
|
|
|
|
});
|
2024-04-01 13:57:39 +02:00
|
|
|
|
2025-01-29 16:00:21 +01:00
|
|
|
const loginSettings = await getLoginSettings({
|
|
|
|
|
serviceUrl,
|
|
|
|
|
serviceRegion,
|
|
|
|
|
organization,
|
|
|
|
|
});
|
2023-06-16 13:57:29 +02:00
|
|
|
|
2024-11-19 15:57:40 +01:00
|
|
|
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>
|
2024-11-19 15:57:40 +01:00
|
|
|
</DynamicTheme>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2024-04-01 13:57:39 +02:00
|
|
|
<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
|
|
|
|
2024-04-01 13:57:39 +02:00
|
|
|
{legal && passwordComplexitySettings && (
|
2024-11-21 14:12:13 +01:00
|
|
|
<RegisterForm
|
2024-04-01 13:57:39 +02:00
|
|
|
legal={legal}
|
|
|
|
|
organization={organization}
|
2024-07-24 13:55:18 +02:00
|
|
|
firstname={firstname}
|
|
|
|
|
lastname={lastname}
|
|
|
|
|
email={email}
|
2024-04-01 13:57:39 +02:00
|
|
|
authRequestId={authRequestId}
|
2024-11-19 15:57:40 +01:00
|
|
|
loginSettings={loginSettings}
|
2024-11-21 14:12:13 +01:00
|
|
|
></RegisterForm>
|
2024-04-01 13:57:39 +02:00
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</DynamicTheme>
|
2023-04-03 13:39:51 +02:00
|
|
|
);
|
|
|
|
|
}
|