mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-13 11:20:00 +00:00
Merge branch 'main' into fix-mid-april
This commit is contained in:
196
apps/login/locales/ru.json
Normal file
196
apps/login/locales/ru.json
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
{
|
||||||
|
"common": {
|
||||||
|
"back": "Назад"
|
||||||
|
},
|
||||||
|
"accounts": {
|
||||||
|
"title": "Аккаунты",
|
||||||
|
"description": "Выберите аккаунт, который хотите использовать.",
|
||||||
|
"addAnother": "Добавить другой аккаунт",
|
||||||
|
"noResults": "Аккаунты не найдены"
|
||||||
|
},
|
||||||
|
"loginname": {
|
||||||
|
"title": "С возвращением!",
|
||||||
|
"description": "Введите свои данные для входа.",
|
||||||
|
"register": "Зарегистрировать нового пользователя"
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"verify": {
|
||||||
|
"title": "Пароль",
|
||||||
|
"description": "Введите ваш пароль.",
|
||||||
|
"resetPassword": "Сбросить пароль",
|
||||||
|
"submit": "Продолжить"
|
||||||
|
},
|
||||||
|
"set": {
|
||||||
|
"title": "Установить пароль",
|
||||||
|
"description": "Установите пароль для вашего аккаунта",
|
||||||
|
"codeSent": "Код отправлен на ваш адрес электронной почты.",
|
||||||
|
"noCodeReceived": "Не получили код?",
|
||||||
|
"resend": "Отправить код повторно",
|
||||||
|
"submit": "Продолжить"
|
||||||
|
},
|
||||||
|
"change": {
|
||||||
|
"title": "Изменить пароль",
|
||||||
|
"description": "Установите пароль для вашего аккаунта",
|
||||||
|
"submit": "Продолжить"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idp": {
|
||||||
|
"title": "Войти через SSO",
|
||||||
|
"description": "Выберите одного из провайдеров для входа",
|
||||||
|
"signInWithApple": "Войти через Apple",
|
||||||
|
"signInWithGoogle": "Войти через Google",
|
||||||
|
"signInWithAzureAD": "Войти через AzureAD",
|
||||||
|
"signInWithGithub": "Войти через GitHub",
|
||||||
|
"signInWithGitlab": "Войти через GitLab",
|
||||||
|
"loginSuccess": {
|
||||||
|
"title": "Вход выполнен успешно",
|
||||||
|
"description": "Вы успешно вошли в систему!"
|
||||||
|
},
|
||||||
|
"linkingSuccess": {
|
||||||
|
"title": "Аккаунт привязан",
|
||||||
|
"description": "Аккаунт успешно привязан!"
|
||||||
|
},
|
||||||
|
"registerSuccess": {
|
||||||
|
"title": "Регистрация завершена",
|
||||||
|
"description": "Вы успешно зарегистрировались!"
|
||||||
|
},
|
||||||
|
"loginError": {
|
||||||
|
"title": "Ошибка входа",
|
||||||
|
"description": "Произошла ошибка при попытке входа."
|
||||||
|
},
|
||||||
|
"linkingError": {
|
||||||
|
"title": "Ошибка привязки аккаунта",
|
||||||
|
"description": "Произошла ошибка при попытке привязать аккаунт."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mfa": {
|
||||||
|
"verify": {
|
||||||
|
"title": "Подтвердите вашу личность",
|
||||||
|
"description": "Выберите один из следующих факторов.",
|
||||||
|
"noResults": "Нет доступных методов двухфакторной аутентификации"
|
||||||
|
},
|
||||||
|
"set": {
|
||||||
|
"title": "Настройка двухфакторной аутентификации",
|
||||||
|
"description": "Выберите один из следующих методов.",
|
||||||
|
"skip": "Пропустить"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"otp": {
|
||||||
|
"verify": {
|
||||||
|
"title": "Подтверждение 2FA",
|
||||||
|
"totpDescription": "Введите код из приложения-аутентификатора.",
|
||||||
|
"smsDescription": "Введите код, полученный по SMS.",
|
||||||
|
"emailDescription": "Введите код, полученный по email.",
|
||||||
|
"noCodeReceived": "Не получили код?",
|
||||||
|
"resendCode": "Отправить код повторно",
|
||||||
|
"submit": "Продолжить"
|
||||||
|
},
|
||||||
|
"set": {
|
||||||
|
"title": "Настройка двухфакторной аутентификации",
|
||||||
|
"totpDescription": "Отсканируйте QR-код в приложении-аутентификаторе.",
|
||||||
|
"smsDescription": "Введите номер телефона для получения кода по SMS.",
|
||||||
|
"emailDescription": "Введите email для получения кода.",
|
||||||
|
"totpRegisterDescription": "Отсканируйте QR-код или перейдите по ссылке вручную.",
|
||||||
|
"submit": "Продолжить"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"passkey": {
|
||||||
|
"verify": {
|
||||||
|
"title": "Аутентификация с помощью пасскей",
|
||||||
|
"description": "Устройство запросит отпечаток пальца, лицо или экранный замок",
|
||||||
|
"usePassword": "Использовать пароль",
|
||||||
|
"submit": "Продолжить"
|
||||||
|
},
|
||||||
|
"set": {
|
||||||
|
"title": "Настройка пасскей",
|
||||||
|
"description": "Устройство запросит отпечаток пальца, лицо или экранный замок",
|
||||||
|
"info": {
|
||||||
|
"description": "Пасскей — метод аутентификации через устройство (отпечаток пальца, Apple FaceID и аналоги).",
|
||||||
|
"link": "Аутентификация без пароля"
|
||||||
|
},
|
||||||
|
"skip": "Пропустить",
|
||||||
|
"submit": "Продолжить"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"u2f": {
|
||||||
|
"verify": {
|
||||||
|
"title": "Подтверждение 2FA",
|
||||||
|
"description": "Подтвердите аккаунт с помощью устройства."
|
||||||
|
},
|
||||||
|
"set": {
|
||||||
|
"title": "Настройка двухфакторной аутентификации",
|
||||||
|
"description": "Настройте устройство как второй фактор.",
|
||||||
|
"submit": "Продолжить"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"register": {
|
||||||
|
"methods": {
|
||||||
|
"passkey": "Пасскей",
|
||||||
|
"password": "Пароль"
|
||||||
|
},
|
||||||
|
"disabled": {
|
||||||
|
"title": "Регистрация отключена",
|
||||||
|
"description": "Регистрация недоступна. Обратитесь к администратору."
|
||||||
|
},
|
||||||
|
"missingdata": {
|
||||||
|
"title": "Недостаточно данных",
|
||||||
|
"description": "Укажите email, имя и фамилию для регистрации."
|
||||||
|
},
|
||||||
|
"title": "Регистрация",
|
||||||
|
"description": "Создайте свой аккаунт ZITADEL.",
|
||||||
|
"selectMethod": "Выберите метод аутентификации",
|
||||||
|
"agreeTo": "Для регистрации необходимо принять условия:",
|
||||||
|
"termsOfService": "Условия использования",
|
||||||
|
"privacyPolicy": "Политика конфиденциальности",
|
||||||
|
"submit": "Продолжить",
|
||||||
|
"password": {
|
||||||
|
"title": "Установить пароль",
|
||||||
|
"description": "Установите пароль для вашего аккаунта",
|
||||||
|
"submit": "Продолжить"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"invite": {
|
||||||
|
"title": "Пригласить пользователя",
|
||||||
|
"description": "Укажите email и имя пользователя для приглашения.",
|
||||||
|
"info": "Пользователь получит email с инструкциями.",
|
||||||
|
"notAllowed": "Ваши настройки не позволяют приглашать пользователей.",
|
||||||
|
"submit": "Продолжить",
|
||||||
|
"success": {
|
||||||
|
"title": "Пользователь приглашён",
|
||||||
|
"description": "Письмо успешно отправлено.",
|
||||||
|
"verified": "Пользователь приглашён и уже подтвердил email.",
|
||||||
|
"notVerifiedYet": "Пользователь приглашён. Он получит email с инструкциями.",
|
||||||
|
"submit": "Пригласить другого пользователя"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"signedin": {
|
||||||
|
"title": "Добро пожаловать, {user}!",
|
||||||
|
"description": "Вы вошли в систему.",
|
||||||
|
"continue": "Продолжить"
|
||||||
|
},
|
||||||
|
"verify": {
|
||||||
|
"userIdMissing": "Не указан userId!",
|
||||||
|
"success": "Пользователь успешно подтверждён.",
|
||||||
|
"setupAuthenticator": "Настроить аутентификатор",
|
||||||
|
"verify": {
|
||||||
|
"title": "Подтверждение пользователя",
|
||||||
|
"description": "Введите код из письма подтверждения.",
|
||||||
|
"noCodeReceived": "Не получили код?",
|
||||||
|
"resendCode": "Отправить код повторно",
|
||||||
|
"submit": "Продолжить"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"authenticator": {
|
||||||
|
"title": "Выбор метода аутентификации",
|
||||||
|
"description": "Выберите предпочитаемый метод аутентификации",
|
||||||
|
"noMethodsAvailable": "Нет доступных методов аутентификации",
|
||||||
|
"allSetup": "Аутентификатор уже настроен!",
|
||||||
|
"linkWithIDP": "или привязать через Identity Provider"
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"unknownContext": "Не удалось получить контекст пользователя. Укажите имя пользователя или loginName в параметрах поиска.",
|
||||||
|
"sessionExpired": "Ваша сессия истекла. Войдите снова.",
|
||||||
|
"failedLoading": "Ошибка загрузки данных. Попробуйте ещё раз.",
|
||||||
|
"tryagain": "Попробовать снова"
|
||||||
|
}
|
||||||
|
}
|
@@ -46,6 +46,7 @@
|
|||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
"deepmerge": "^4.3.1",
|
"deepmerge": "^4.3.1",
|
||||||
"jose": "^5.3.0",
|
"jose": "^5.3.0",
|
||||||
|
"lucide-react": "0.469.0",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"next": "15.3.1-canary.9",
|
"next": "15.3.1-canary.9",
|
||||||
"next-intl": "^3.25.1",
|
"next-intl": "^3.25.1",
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { clsx } from "clsx";
|
import { clsx } from "clsx";
|
||||||
|
import { Loader2Icon } from "lucide-react";
|
||||||
import { ButtonHTMLAttributes, DetailedHTMLProps, forwardRef } from "react";
|
import { ButtonHTMLAttributes, DetailedHTMLProps, forwardRef } from "react";
|
||||||
|
import { useFormStatus } from "react-dom";
|
||||||
|
|
||||||
export type SignInWithIdentityProviderProps = DetailedHTMLProps<
|
export type SignInWithIdentityProviderProps = DetailedHTMLProps<
|
||||||
ButtonHTMLAttributes<HTMLButtonElement>,
|
ButtonHTMLAttributes<HTMLButtonElement>,
|
||||||
@@ -15,15 +17,25 @@ export const BaseButton = forwardRef<
|
|||||||
HTMLButtonElement,
|
HTMLButtonElement,
|
||||||
SignInWithIdentityProviderProps
|
SignInWithIdentityProviderProps
|
||||||
>(function BaseButton(props, ref) {
|
>(function BaseButton(props, ref) {
|
||||||
|
const formStatus = useFormStatus();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
{...props}
|
{...props}
|
||||||
type="button"
|
type="submit"
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
disabled={formStatus.pending}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"transition-all cursor-pointer flex flex-row items-center bg-background-light-400 text-text-light-500 dark:bg-background-dark-500 dark:text-text-dark-500 border border-divider-light hover:border-black dark:border-divider-dark hover:dark:border-white focus:border-primary-light-500 focus:dark:border-primary-dark-500 outline-none rounded-md px-4 text-sm",
|
"flex-1 transition-all cursor-pointer flex flex-row items-center bg-background-light-400 text-text-light-500 dark:bg-background-dark-500 dark:text-text-dark-500 border border-divider-light hover:border-black dark:border-divider-dark hover:dark:border-white focus:border-primary-light-500 focus:dark:border-primary-dark-500 outline-none rounded-md px-4 text-sm",
|
||||||
props.className,
|
props.className,
|
||||||
)}
|
)}
|
||||||
/>
|
>
|
||||||
|
<div className="flex-1 justify-between flex items-center gap-4">
|
||||||
|
<div className="flex-1 flex flex-row items-center">
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
{formStatus.pending && <Loader2Icon className="w-4 h-4 animate-spin" />}
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -4,6 +4,39 @@ import { useTranslations } from "next-intl";
|
|||||||
import { forwardRef } from "react";
|
import { forwardRef } from "react";
|
||||||
import { BaseButton, SignInWithIdentityProviderProps } from "./base-button";
|
import { BaseButton, SignInWithIdentityProviderProps } from "./base-button";
|
||||||
|
|
||||||
|
function GitHubLogo() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 1024 1024"
|
||||||
|
className="h-8 w-8 hidden dark:block"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill="#fafafa"
|
||||||
|
fillRule="evenodd"
|
||||||
|
d="M512 0C229.12 0 0 229.12 0 512c0 226.56 146.56 417.92 350.08 485.76 25.6 4.48 35.2-10.88 35.2-24.32 0-12.16-.64-52.48-.64-95.36-128.64 23.68-161.92-31.36-172.16-60.16-5.76-14.72-30.72-60.16-52.48-72.32-17.92-9.6-43.52-33.28-.64-33.92 40.32-.64 69.12 37.12 78.72 52.48 46.08 77.44 119.68 55.68 149.12 42.24 4.48-33.28 17.92-55.68 32.64-68.48-113.92-12.8-232.96-56.96-232.96-252.8 0-55.68 19.84-101.76 52.48-137.6-5.12-12.8-23.04-65.28 5.12-135.68 0 0 42.88-13.44 140.8 52.48 40.96-11.52 84.48-17.28 128-17.28 43.52 0 87.04 5.76 128 17.28 97.92-66.56 140.8-52.48 140.8-52.48 28.16 70.4 10.24 122.88 5.12 135.68 32.64 35.84 52.48 81.28 52.48 137.6 0 196.48-119.68 240-233.6 252.8 18.56 16 34.56 46.72 34.56 94.72 0 68.48-.64 123.52-.64 140.8 0 13.44 9.6 29.44 35.2 24.32C877.44 929.92 1024 737.92 1024 512 1024 229.12 794.88 0 512 0z"
|
||||||
|
clipRule="evenodd"
|
||||||
|
></path>
|
||||||
|
</svg>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 1024 1024"
|
||||||
|
className="h-8 w-8 block dark:hidden"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill="#1B1F23"
|
||||||
|
fillRule="evenodd"
|
||||||
|
d="M512 0C229.12 0 0 229.12 0 512c0 226.56 146.56 417.92 350.08 485.76 25.6 4.48 35.2-10.88 35.2-24.32 0-12.16-.64-52.48-.64-95.36-128.64 23.68-161.92-31.36-172.16-60.16-5.76-14.72-30.72-60.16-52.48-72.32-17.92-9.6-43.52-33.28-.64-33.92 40.32-.64 69.12 37.12 78.72 52.48 46.08 77.44 119.68 55.68 149.12 42.24 4.48-33.28 17.92-55.68 32.64-68.48-113.92-12.8-232.96-56.96-232.96-252.8 0-55.68 19.84-101.76 52.48-137.6-5.12-12.8-23.04-65.28 5.12-135.68 0 0 42.88-13.44 140.8 52.48 40.96-11.52 84.48-17.28 128-17.28 43.52 0 87.04 5.76 128 17.28 97.92-66.56 140.8-52.48 140.8-52.48 28.16 70.4 10.24 122.88 5.12 135.68 32.64 35.84 52.48 81.28 52.48 137.6 0 196.48-119.68 240-233.6 252.8 18.56 16 34.56 46.72 34.56 94.72 0 68.48-.64 123.52-.64 140.8 0 13.44 9.6 29.44 35.2 24.32C877.44 929.92 1024 737.92 1024 512 1024 229.12 794.88 0 512 0z"
|
||||||
|
clipRule="evenodd"
|
||||||
|
></path>
|
||||||
|
</svg>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export const SignInWithGithub = forwardRef<
|
export const SignInWithGithub = forwardRef<
|
||||||
HTMLButtonElement,
|
HTMLButtonElement,
|
||||||
SignInWithIdentityProviderProps
|
SignInWithIdentityProviderProps
|
||||||
@@ -14,32 +47,7 @@ export const SignInWithGithub = forwardRef<
|
|||||||
return (
|
return (
|
||||||
<BaseButton {...restProps} ref={ref}>
|
<BaseButton {...restProps} ref={ref}>
|
||||||
<div className="mx-2 my-2 flex items-center justify-center">
|
<div className="mx-2 my-2 flex items-center justify-center">
|
||||||
<svg
|
<GitHubLogo />
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 1024 1024"
|
|
||||||
className="h-8 w-8 hidden dark:block"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fill="#fafafa"
|
|
||||||
fillRule="evenodd"
|
|
||||||
d="M512 0C229.12 0 0 229.12 0 512c0 226.56 146.56 417.92 350.08 485.76 25.6 4.48 35.2-10.88 35.2-24.32 0-12.16-.64-52.48-.64-95.36-128.64 23.68-161.92-31.36-172.16-60.16-5.76-14.72-30.72-60.16-52.48-72.32-17.92-9.6-43.52-33.28-.64-33.92 40.32-.64 69.12 37.12 78.72 52.48 46.08 77.44 119.68 55.68 149.12 42.24 4.48-33.28 17.92-55.68 32.64-68.48-113.92-12.8-232.96-56.96-232.96-252.8 0-55.68 19.84-101.76 52.48-137.6-5.12-12.8-23.04-65.28 5.12-135.68 0 0 42.88-13.44 140.8 52.48 40.96-11.52 84.48-17.28 128-17.28 43.52 0 87.04 5.76 128 17.28 97.92-66.56 140.8-52.48 140.8-52.48 28.16 70.4 10.24 122.88 5.12 135.68 32.64 35.84 52.48 81.28 52.48 137.6 0 196.48-119.68 240-233.6 252.8 18.56 16 34.56 46.72 34.56 94.72 0 68.48-.64 123.52-.64 140.8 0 13.44 9.6 29.44 35.2 24.32C877.44 929.92 1024 737.92 1024 512 1024 229.12 794.88 0 512 0z"
|
|
||||||
clipRule="evenodd"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 1024 1024"
|
|
||||||
className="h-8 w-8 block dark:hidden"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fill="#1B1F23"
|
|
||||||
fillRule="evenodd"
|
|
||||||
d="M512 0C229.12 0 0 229.12 0 512c0 226.56 146.56 417.92 350.08 485.76 25.6 4.48 35.2-10.88 35.2-24.32 0-12.16-.64-52.48-.64-95.36-128.64 23.68-161.92-31.36-172.16-60.16-5.76-14.72-30.72-60.16-52.48-72.32-17.92-9.6-43.52-33.28-.64-33.92 40.32-.64 69.12 37.12 78.72 52.48 46.08 77.44 119.68 55.68 149.12 42.24 4.48-33.28 17.92-55.68 32.64-68.48-113.92-12.8-232.96-56.96-232.96-252.8 0-55.68 19.84-101.76 52.48-137.6-5.12-12.8-23.04-65.28 5.12-135.68 0 0 42.88-13.44 140.8 52.48 40.96-11.52 84.48-17.28 128-17.28 43.52 0 87.04 5.76 128 17.28 97.92-66.56 140.8-52.48 140.8-52.48 28.16 70.4 10.24 122.88 5.12 135.68 32.64 35.84 52.48 81.28 52.48 137.6 0 196.48-119.68 240-233.6 252.8 18.56 16 34.56 46.72 34.56 94.72 0 68.48-.64 123.52-.64 140.8 0 13.44 9.6 29.44 35.2 24.32C877.44 929.92 1024 737.92 1024 512 1024 229.12 794.88 0 512 0z"
|
|
||||||
clipRule="evenodd"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
</div>
|
</div>
|
||||||
{children ? (
|
{children ? (
|
||||||
children
|
children
|
||||||
|
@@ -1,13 +1,12 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { idpTypeToSlug } from "@/lib/idp";
|
import { idpTypeToSlug } from "@/lib/idp";
|
||||||
import { startIDPFlow } from "@/lib/server/idp";
|
import { redirectToIdp } from "@/lib/server/idp";
|
||||||
import {
|
import {
|
||||||
IdentityProvider,
|
IdentityProvider,
|
||||||
IdentityProviderType,
|
IdentityProviderType,
|
||||||
} from "@zitadel/proto/zitadel/settings/v2/login_settings_pb";
|
} from "@zitadel/proto/zitadel/settings/v2/login_settings_pb";
|
||||||
import { useRouter } from "next/navigation";
|
import { ReactNode, useActionState } from "react";
|
||||||
import { ReactNode, useCallback, useState } from "react";
|
|
||||||
import { Alert } from "./alert";
|
import { Alert } from "./alert";
|
||||||
import { SignInWithIdentityProviderProps } from "./idps/base-button";
|
import { SignInWithIdentityProviderProps } from "./idps/base-button";
|
||||||
import { SignInWithApple } from "./idps/sign-in-with-apple";
|
import { SignInWithApple } from "./idps/sign-in-with-apple";
|
||||||
@@ -31,45 +30,10 @@ export function SignInWithIdp({
|
|||||||
organization,
|
organization,
|
||||||
linkOnly,
|
linkOnly,
|
||||||
}: Readonly<SignInWithIDPProps>) {
|
}: Readonly<SignInWithIDPProps>) {
|
||||||
const [loading, setLoading] = useState(false);
|
const [state, action, _isPending] = useActionState(redirectToIdp, {});
|
||||||
const [error, setError] = useState<string | null>(null);
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const startFlow = useCallback(
|
const renderIDPButton = (idp: IdentityProvider, index: number) => {
|
||||||
async (idpId: string, provider: string) => {
|
|
||||||
setLoading(true);
|
|
||||||
const params = new URLSearchParams();
|
|
||||||
if (linkOnly) params.set("link", "true");
|
|
||||||
if (requestId) params.set("requestId", requestId);
|
|
||||||
if (organization) params.set("organization", organization);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await startIDPFlow({
|
|
||||||
idpId,
|
|
||||||
successUrl: `/idp/${provider}/success?` + params.toString(),
|
|
||||||
failureUrl: `/idp/${provider}/failure?` + params.toString(),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response && "error" in response && response?.error) {
|
|
||||||
setError(response.error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response && "redirect" in response && response?.redirect) {
|
|
||||||
return router.push(response.redirect);
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
setError("Could not start IDP flow");
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[requestId, organization, linkOnly, router],
|
|
||||||
);
|
|
||||||
|
|
||||||
const renderIDPButton = (idp: IdentityProvider) => {
|
|
||||||
const { id, name, type } = idp;
|
const { id, name, type } = idp;
|
||||||
const onClick = () => startFlow(id, idpTypeToSlug(type));
|
|
||||||
|
|
||||||
const components: Partial<
|
const components: Partial<
|
||||||
Record<
|
Record<
|
||||||
@@ -93,16 +57,27 @@ export function SignInWithIdp({
|
|||||||
|
|
||||||
const Component = components[type];
|
const Component = components[type];
|
||||||
return Component ? (
|
return Component ? (
|
||||||
<Component key={id} name={name} onClick={onClick} />
|
<form action={action} className="flex" key={`idp-${index}`}>
|
||||||
|
<input type="hidden" name="id" value={id} />
|
||||||
|
<input type="hidden" name="provider" value={idpTypeToSlug(type)} />
|
||||||
|
<input type="hidden" name="requestId" value={requestId} />
|
||||||
|
<input type="hidden" name="organization" value={organization} />
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="linkOnly"
|
||||||
|
value={linkOnly ? "true" : "false"}
|
||||||
|
/>
|
||||||
|
<Component key={id} name={name} />
|
||||||
|
</form>
|
||||||
) : null;
|
) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col w-full space-y-2 text-sm">
|
<div className="flex flex-col w-full space-y-2 text-sm">
|
||||||
{identityProviders?.map(renderIDPButton)}
|
{identityProviders?.map(renderIDPButton)}
|
||||||
{error && (
|
{state?.error && (
|
||||||
<div className="py-4">
|
<div className="py-4">
|
||||||
<Alert>{error}</Alert>
|
<Alert>{state?.error}</Alert>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@@ -28,6 +28,10 @@ export const LANGS: Lang[] = [
|
|||||||
name: "简体中文",
|
name: "简体中文",
|
||||||
code: "zh",
|
code: "zh",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Русский",
|
||||||
|
code: "ru",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const LANGUAGE_COOKIE_NAME = "NEXT_LOCALE";
|
export const LANGUAGE_COOKIE_NAME = "NEXT_LOCALE";
|
||||||
|
@@ -6,11 +6,45 @@ import {
|
|||||||
startIdentityProviderFlow,
|
startIdentityProviderFlow,
|
||||||
} from "@/lib/zitadel";
|
} from "@/lib/zitadel";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
import { getNextUrl } from "../client";
|
import { getNextUrl } from "../client";
|
||||||
import { getServiceUrlFromHeaders } from "../service";
|
import { getServiceUrlFromHeaders } from "../service";
|
||||||
import { checkEmailVerification } from "../verify-helper";
|
import { checkEmailVerification } from "../verify-helper";
|
||||||
import { createSessionForIdpAndUpdateCookie } from "./cookie";
|
import { createSessionForIdpAndUpdateCookie } from "./cookie";
|
||||||
|
|
||||||
|
export type RedirectToIdpState = { error?: string | null } | undefined;
|
||||||
|
|
||||||
|
export async function redirectToIdp(
|
||||||
|
prevState: RedirectToIdpState,
|
||||||
|
formData: FormData,
|
||||||
|
): Promise<RedirectToIdpState> {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
const linkOnly = formData.get("linkOnly") === "true";
|
||||||
|
const requestId = formData.get("requestId") as string;
|
||||||
|
const organization = formData.get("organization") as string;
|
||||||
|
const idpId = formData.get("id") as string;
|
||||||
|
const provider = formData.get("provider") as string;
|
||||||
|
|
||||||
|
if (linkOnly) params.set("link", "true");
|
||||||
|
if (requestId) params.set("requestId", requestId);
|
||||||
|
if (organization) params.set("organization", organization);
|
||||||
|
|
||||||
|
const response = await startIDPFlow({
|
||||||
|
idpId,
|
||||||
|
successUrl: `/idp/${provider}/success?` + params.toString(),
|
||||||
|
failureUrl: `/idp/${provider}/failure?` + params.toString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response && "error" in response && response?.error) {
|
||||||
|
return { error: response.error };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response && "redirect" in response && response?.redirect) {
|
||||||
|
redirect(response.redirect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type StartIDPFlowCommand = {
|
export type StartIDPFlowCommand = {
|
||||||
idpId: string;
|
idpId: string;
|
||||||
successUrl: string;
|
successUrl: string;
|
||||||
|
25
pnpm-lock.yaml
generated
25
pnpm-lock.yaml
generated
@@ -104,6 +104,9 @@ importers:
|
|||||||
jose:
|
jose:
|
||||||
specifier: ^5.3.0
|
specifier: ^5.3.0
|
||||||
version: 5.8.0
|
version: 5.8.0
|
||||||
|
lucide-react:
|
||||||
|
specifier: 0.469.0
|
||||||
|
version: 0.469.0(react@19.0.0)
|
||||||
moment:
|
moment:
|
||||||
specifier: ^2.29.4
|
specifier: ^2.29.4
|
||||||
version: 2.30.1
|
version: 2.30.1
|
||||||
@@ -1489,9 +1492,6 @@ packages:
|
|||||||
'@swc/counter@0.1.3':
|
'@swc/counter@0.1.3':
|
||||||
resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==}
|
resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==}
|
||||||
|
|
||||||
'@swc/helpers@0.5.13':
|
|
||||||
resolution: {integrity: sha512-UoKGxQ3r5kYI9dALKJapMmuK+1zWM/H17Z1+iwnNmzcJRnfFuevZs375TA5rW31pu4BS4NoSy1fRsexDXfWn5w==}
|
|
||||||
|
|
||||||
'@swc/helpers@0.5.15':
|
'@swc/helpers@0.5.15':
|
||||||
resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==}
|
resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==}
|
||||||
|
|
||||||
@@ -3389,6 +3389,11 @@ packages:
|
|||||||
lru-cache@5.1.1:
|
lru-cache@5.1.1:
|
||||||
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
|
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
|
||||||
|
|
||||||
|
lucide-react@0.469.0:
|
||||||
|
resolution: {integrity: sha512-28vvUnnKQ/dBwiCQtwJw7QauYnE7yd2Cyp4tTTJpvglX4EMpbflcdBgrgToX2j71B3YvugK/NH3BGUk+E/p/Fw==}
|
||||||
|
peerDependencies:
|
||||||
|
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||||
|
|
||||||
lz-string@1.5.0:
|
lz-string@1.5.0:
|
||||||
resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==}
|
resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
@@ -5902,7 +5907,7 @@ snapshots:
|
|||||||
|
|
||||||
'@react-aria/ssr@3.9.6(react@19.0.0)':
|
'@react-aria/ssr@3.9.6(react@19.0.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@swc/helpers': 0.5.5
|
'@swc/helpers': 0.5.15
|
||||||
react: 19.0.0
|
react: 19.0.0
|
||||||
|
|
||||||
'@react-aria/utils@3.25.3(react@19.0.0)':
|
'@react-aria/utils@3.25.3(react@19.0.0)':
|
||||||
@@ -5910,13 +5915,13 @@ snapshots:
|
|||||||
'@react-aria/ssr': 3.9.6(react@19.0.0)
|
'@react-aria/ssr': 3.9.6(react@19.0.0)
|
||||||
'@react-stately/utils': 3.10.4(react@19.0.0)
|
'@react-stately/utils': 3.10.4(react@19.0.0)
|
||||||
'@react-types/shared': 3.25.0(react@19.0.0)
|
'@react-types/shared': 3.25.0(react@19.0.0)
|
||||||
'@swc/helpers': 0.5.5
|
'@swc/helpers': 0.5.15
|
||||||
clsx: 2.1.1
|
clsx: 2.1.1
|
||||||
react: 19.0.0
|
react: 19.0.0
|
||||||
|
|
||||||
'@react-stately/utils@3.10.4(react@19.0.0)':
|
'@react-stately/utils@3.10.4(react@19.0.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@swc/helpers': 0.5.13
|
'@swc/helpers': 0.5.15
|
||||||
react: 19.0.0
|
react: 19.0.0
|
||||||
|
|
||||||
'@react-types/shared@3.25.0(react@19.0.0)':
|
'@react-types/shared@3.25.0(react@19.0.0)':
|
||||||
@@ -5991,10 +5996,6 @@ snapshots:
|
|||||||
|
|
||||||
'@swc/counter@0.1.3': {}
|
'@swc/counter@0.1.3': {}
|
||||||
|
|
||||||
'@swc/helpers@0.5.13':
|
|
||||||
dependencies:
|
|
||||||
tslib: 2.8.1
|
|
||||||
|
|
||||||
'@swc/helpers@0.5.15':
|
'@swc/helpers@0.5.15':
|
||||||
dependencies:
|
dependencies:
|
||||||
tslib: 2.8.1
|
tslib: 2.8.1
|
||||||
@@ -8254,6 +8255,10 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
yallist: 3.1.1
|
yallist: 3.1.1
|
||||||
|
|
||||||
|
lucide-react@0.469.0(react@19.0.0):
|
||||||
|
dependencies:
|
||||||
|
react: 19.0.0
|
||||||
|
|
||||||
lz-string@1.5.0: {}
|
lz-string@1.5.0: {}
|
||||||
|
|
||||||
magic-string@0.30.12:
|
magic-string@0.30.12:
|
||||||
|
Reference in New Issue
Block a user