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",
"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",
"agreeTo": "Um sich zu registrieren, müssen Sie den Nutzungsbedingungen zustimmen",
"termsOfService": "Nutzungsbedingungen",
"privacyPolicy": "Datenschutzrichtlinie",
"submit": "Weiter",
"orUseIDP": "oder verwenden Sie einen Identitätsanbieter",
"password": {
"title": "Passwort festlegen",
"description": "Legen Sie das Passwort für Ihr Konto fest",

View File

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

View File

@@ -149,11 +149,13 @@
},
"title": "Registrarse",
"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",
"agreeTo": "Para registrarte debes aceptar los términos y condiciones",
"termsOfService": "Términos de Servicio",
"privacyPolicy": "Política de Privacidad",
"submit": "Continuar",
"orUseIDP": "o usa un Proveedor de Identidad",
"password": {
"title": "Establecer Contraseña",
"description": "Establece la contraseña para tu cuenta",

View File

@@ -149,11 +149,13 @@
},
"title": "Registrati",
"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",
"agreeTo": "Per registrarti devi accettare i termini e le condizioni",
"termsOfService": "Termini di Servizio",
"privacyPolicy": "Informativa sulla Privacy",
"submit": "Continua",
"orUseIDP": "o usa un Identity Provider",
"password": {
"title": "Imposta Password",
"description": "Imposta la password per il tuo account",

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,9 @@
import { DynamicTheme } from "@/components/dynamic-theme";
import { RegisterForm } from "@/components/register-form";
import { SignInWithIdp } from "@/components/sign-in-with-idp";
import { getServiceUrlFromHeaders } from "@/lib/service-url";
import {
getActiveIdentityProviders,
getBrandingSettings,
getDefaultOrg,
getLegalAndSupportSettings,
@@ -72,6 +74,15 @@ export default async function Page(props: {
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) {
return (
<DynamicTheme branding={branding}>
@@ -91,6 +102,9 @@ export default async function Page(props: {
{legal && passwordComplexitySettings && (
<RegisterForm
idpCount={
!loginSettings?.allowExternalIdp ? 0 : identityProviders.length
}
legal={legal}
organization={organization}
firstname={firstname}
@@ -100,6 +114,20 @@ export default async function Page(props: {
loginSettings={loginSettings}
></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>
</DynamicTheme>
);

View File

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