conditionally hide options

This commit is contained in:
Max Peintner
2025-06-06 13:46:25 +02:00
parent 2af4361925
commit 738f1f0448
9 changed files with 52 additions and 1 deletions

View File

@@ -149,11 +149,13 @@
}, },
"title": "Registrieren", "title": "Registrieren",
"description": "Erstellen Sie Ihr ZITADEL-Konto.", "description": "Erstellen Sie Ihr ZITADEL-Konto.",
"noMethodAvailableWarning": "Keine Authentifizierungsmethode verfügbar. Bitte wenden Sie sich an den Administrator.",
"selectMethod": "Wählen Sie die Methode, mit der Sie sich authentifizieren möchten", "selectMethod": "Wählen Sie die Methode, mit der Sie sich authentifizieren möchten",
"agreeTo": "Um sich zu registrieren, müssen Sie den Nutzungsbedingungen zustimmen", "agreeTo": "Um sich zu registrieren, müssen Sie den Nutzungsbedingungen zustimmen",
"termsOfService": "Nutzungsbedingungen", "termsOfService": "Nutzungsbedingungen",
"privacyPolicy": "Datenschutzrichtlinie", "privacyPolicy": "Datenschutzrichtlinie",
"submit": "Weiter", "submit": "Weiter",
"orUseIDP": "oder verwenden Sie einen Identitätsanbieter",
"password": { "password": {
"title": "Passwort festlegen", "title": "Passwort festlegen",
"description": "Legen Sie das Passwort für Ihr Konto fest", "description": "Legen Sie das Passwort für Ihr Konto fest",

View File

@@ -149,11 +149,13 @@
}, },
"title": "Register", "title": "Register",
"description": "Create your ZITADEL account.", "description": "Create your ZITADEL account.",
"noMethodAvailableWarning": "No authentication method available. Please contact your administrator.",
"selectMethod": "Select the method you would like to authenticate", "selectMethod": "Select the method you would like to authenticate",
"agreeTo": "To register you must agree to the terms and conditions", "agreeTo": "To register you must agree to the terms and conditions",
"termsOfService": "Terms of Service", "termsOfService": "Terms of Service",
"privacyPolicy": "Privacy Policy", "privacyPolicy": "Privacy Policy",
"submit": "Continue", "submit": "Continue",
"orUseIDP": "or use an Identity Provider",
"password": { "password": {
"title": "Set Password", "title": "Set Password",
"description": "Set the password for your account", "description": "Set the password for your account",

View File

@@ -149,11 +149,13 @@
}, },
"title": "Registrarse", "title": "Registrarse",
"description": "Crea tu cuenta ZITADEL.", "description": "Crea tu cuenta ZITADEL.",
"noMethodAvailableWarning": "No hay métodos de autenticación disponibles. Por favor, contacta a tu administrador.",
"selectMethod": "Selecciona el método con el que deseas autenticarte", "selectMethod": "Selecciona el método con el que deseas autenticarte",
"agreeTo": "Para registrarte debes aceptar los términos y condiciones", "agreeTo": "Para registrarte debes aceptar los términos y condiciones",
"termsOfService": "Términos de Servicio", "termsOfService": "Términos de Servicio",
"privacyPolicy": "Política de Privacidad", "privacyPolicy": "Política de Privacidad",
"submit": "Continuar", "submit": "Continuar",
"orUseIDP": "o usa un Proveedor de Identidad",
"password": { "password": {
"title": "Establecer Contraseña", "title": "Establecer Contraseña",
"description": "Establece la contraseña para tu cuenta", "description": "Establece la contraseña para tu cuenta",

View File

@@ -149,11 +149,13 @@
}, },
"title": "Registrati", "title": "Registrati",
"description": "Crea il tuo account ZITADEL.", "description": "Crea il tuo account ZITADEL.",
"noMethodAvailableWarning": "Nessun metodo di autenticazione disponibile. Contatta l'amministratore di sistema per assistenza.",
"selectMethod": "Seleziona il metodo con cui desideri autenticarti", "selectMethod": "Seleziona il metodo con cui desideri autenticarti",
"agreeTo": "Per registrarti devi accettare i termini e le condizioni", "agreeTo": "Per registrarti devi accettare i termini e le condizioni",
"termsOfService": "Termini di Servizio", "termsOfService": "Termini di Servizio",
"privacyPolicy": "Informativa sulla Privacy", "privacyPolicy": "Informativa sulla Privacy",
"submit": "Continua", "submit": "Continua",
"orUseIDP": "o usa un Identity Provider",
"password": { "password": {
"title": "Imposta Password", "title": "Imposta Password",
"description": "Imposta la password per il tuo account", "description": "Imposta la password per il tuo account",

View File

@@ -149,11 +149,13 @@
}, },
"title": "Rejestracja", "title": "Rejestracja",
"description": "Utwórz konto ZITADEL.", "description": "Utwórz konto ZITADEL.",
"noMethodAvailableWarning": "Brak dostępnych metod uwierzytelniania. Skontaktuj się z administratorem.",
"selectMethod": "Wybierz metodę uwierzytelniania, której chcesz użyć", "selectMethod": "Wybierz metodę uwierzytelniania, której chcesz użyć",
"agreeTo": "Aby się zarejestrować, musisz zaakceptować warunki korzystania", "agreeTo": "Aby się zarejestrować, musisz zaakceptować warunki korzystania",
"termsOfService": "Regulamin", "termsOfService": "Regulamin",
"privacyPolicy": "Polityka prywatności", "privacyPolicy": "Polityka prywatności",
"submit": "Kontynuuj", "submit": "Kontynuuj",
"orUseIDP": "lub użyj dostawcy tożsamości",
"password": { "password": {
"title": "Ustaw hasło", "title": "Ustaw hasło",
"description": "Ustaw hasło dla swojego konta", "description": "Ustaw hasło dla swojego konta",

View File

@@ -149,11 +149,13 @@
}, },
"title": "Регистрация", "title": "Регистрация",
"description": "Создайте свой аккаунт ZITADEL.", "description": "Создайте свой аккаунт ZITADEL.",
"noMethodAvailableWarning": "Нет доступных методов аутентификации. Обратитесь к администратору.",
"selectMethod": "Выберите метод аутентификации", "selectMethod": "Выберите метод аутентификации",
"agreeTo": "Для регистрации необходимо принять условия:", "agreeTo": "Для регистрации необходимо принять условия:",
"termsOfService": "Условия использования", "termsOfService": "Условия использования",
"privacyPolicy": "Политика конфиденциальности", "privacyPolicy": "Политика конфиденциальности",
"submit": "Продолжить", "submit": "Продолжить",
"orUseIDP": "или используйте Identity Provider",
"password": { "password": {
"title": "Установить пароль", "title": "Установить пароль",
"description": "Установите пароль для вашего аккаунта", "description": "Установите пароль для вашего аккаунта",

View File

@@ -149,11 +149,13 @@
}, },
"title": "注册", "title": "注册",
"description": "创建您的 ZITADEL 账户。", "description": "创建您的 ZITADEL 账户。",
"noMethodAvailableWarning": "没有可用的认证方法。请联系您的系统管理员。",
"selectMethod": "选择您想使用的认证方法", "selectMethod": "选择您想使用的认证方法",
"agreeTo": "注册即表示您同意条款和条件", "agreeTo": "注册即表示您同意条款和条件",
"termsOfService": "服务条款", "termsOfService": "服务条款",
"privacyPolicy": "隐私政策", "privacyPolicy": "隐私政策",
"submit": "继续", "submit": "继续",
"orUseIDP": "或使用身份提供者",
"password": { "password": {
"title": "设置密码", "title": "设置密码",
"description": "为您的账户设置密码", "description": "为您的账户设置密码",

View File

@@ -1,7 +1,9 @@
import { DynamicTheme } from "@/components/dynamic-theme"; import { DynamicTheme } from "@/components/dynamic-theme";
import { RegisterForm } from "@/components/register-form"; import { RegisterForm } from "@/components/register-form";
import { SignInWithIdp } from "@/components/sign-in-with-idp";
import { getServiceUrlFromHeaders } from "@/lib/service-url"; import { getServiceUrlFromHeaders } from "@/lib/service-url";
import { import {
getActiveIdentityProviders,
getBrandingSettings, getBrandingSettings,
getDefaultOrg, getDefaultOrg,
getLegalAndSupportSettings, getLegalAndSupportSettings,
@@ -72,6 +74,15 @@ export default async function Page(props: {
organization, organization,
}); });
const identityProviders = await getActiveIdentityProviders({
serviceUrl,
orgId: organization,
}).then((resp) => {
return resp.identityProviders.filter((idp) => {
return idp.options?.isAutoCreation || idp.options?.isCreationAllowed; // check if IDP allows to create account automatically or manual creation is allowed
});
});
if (!loginSettings?.allowRegister) { if (!loginSettings?.allowRegister) {
return ( return (
<DynamicTheme branding={branding}> <DynamicTheme branding={branding}>
@@ -91,6 +102,9 @@ export default async function Page(props: {
{legal && passwordComplexitySettings && ( {legal && passwordComplexitySettings && (
<RegisterForm <RegisterForm
idpCount={
!loginSettings?.allowExternalIdp ? 0 : identityProviders.length
}
legal={legal} legal={legal}
organization={organization} organization={organization}
firstname={firstname} firstname={firstname}
@@ -100,6 +114,20 @@ export default async function Page(props: {
loginSettings={loginSettings} loginSettings={loginSettings}
></RegisterForm> ></RegisterForm>
)} )}
{loginSettings?.allowExternalIdp && !!identityProviders.length && (
<>
<div className="py-3 flex flex-col items-center">
<p className="ztdl-p text-center">{t("orUseIDP")}</p>
</div>
<SignInWithIdp
identityProviders={identityProviders}
requestId={requestId}
organization={organization}
></SignInWithIdp>
</>
)}
</div> </div>
</DynamicTheme> </DynamicTheme>
); );

View File

@@ -10,7 +10,7 @@ import { useTranslations } from "next-intl";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useState } from "react"; import { useState } from "react";
import { FieldValues, useForm } from "react-hook-form"; import { FieldValues, useForm } from "react-hook-form";
import { Alert } from "./alert"; import { Alert, AlertType } from "./alert";
import { import {
AuthenticationMethod, AuthenticationMethod,
AuthenticationMethodRadio, AuthenticationMethodRadio,
@@ -38,6 +38,7 @@ type Props = {
organization?: string; organization?: string;
requestId?: string; requestId?: string;
loginSettings?: LoginSettings; loginSettings?: LoginSettings;
idpCount: number;
}; };
export function RegisterForm({ export function RegisterForm({
@@ -48,6 +49,7 @@ export function RegisterForm({
organization, organization,
requestId, requestId,
loginSettings, loginSettings,
idpCount = 0,
}: Props) { }: Props) {
const t = useTranslations("register"); const t = useTranslations("register");
@@ -178,11 +180,18 @@ export function RegisterForm({
</div> </div>
)} )}
{(!loginSettings?.allowUsernamePassword ||
loginSettings?.passkeysType != PasskeysType.ALLOWED) &&
!idpCount && (
<Alert type={AlertType.INFO}>{t("noMethodAvailableWarning")}</Alert>
)}
{error && ( {error && (
<div className="py-4"> <div className="py-4">
<Alert>{error}</Alert> <Alert>{error}</Alert>
</div> </div>
)} )}
<div className="mt-8 flex w-full flex-row items-center justify-between"> <div className="mt-8 flex w-full flex-row items-center justify-between">
<BackButton data-testid="back-button" /> <BackButton data-testid="back-button" />
<Button <Button