diff --git a/apps/login/src/app/(login)/idp/[provider]/success/page.tsx b/apps/login/src/app/(login)/idp/[provider]/success/page.tsx index 200c3108a6..4ae6126c77 100644 --- a/apps/login/src/app/(login)/idp/[provider]/success/page.tsx +++ b/apps/login/src/app/(login)/idp/[provider]/success/page.tsx @@ -1,6 +1,9 @@ -import { Alert, AlertType } from "@/components/alert"; import { DynamicTheme } from "@/components/dynamic-theme"; import { IdpSignin } from "@/components/idp-signin"; +import { linkingFailed } from "@/components/idps/pages/linking-failed"; +import { linkingSuccess } from "@/components/idps/pages/linking-success"; +import { loginFailed } from "@/components/idps/pages/login-failed"; +import { loginSuccess } from "@/components/idps/pages/login-success"; import { idpTypeToIdentityProviderType, PROVIDER_MAPPING } from "@/lib/idp"; import { addHuman, @@ -15,7 +18,6 @@ import { import { create } from "@zitadel/client"; import { AutoLinkingOption } from "@zitadel/proto/zitadel/idp/v2/idp_pb"; import { OrganizationSchema } from "@zitadel/proto/zitadel/object/v2/object_pb"; -import { BrandingSettings } from "@zitadel/proto/zitadel/settings/v2/branding_settings_pb"; import { AddHumanUserRequest, AddHumanUserRequestSchema, @@ -24,95 +26,6 @@ import { getLocale, getTranslations } from "next-intl/server"; const ORG_SUFFIX_REGEX = /(?<=@)(.+)/; -async function loginFailed(branding?: BrandingSettings, error: string = "") { - const locale = getLocale(); - const t = await getTranslations({ locale, namespace: "idp" }); - - return ( - -
-

{t("loginError.title")}

-

{t("loginError.description")}

- {error && ( -
- {{error}} -
- )} -
-
- ); -} - -async function loginSuccess( - userId: string, - idpIntent: { idpIntentId: string; idpIntentToken: string }, - authRequestId?: string, - branding?: BrandingSettings, -) { - const locale = getLocale(); - const t = await getTranslations({ locale, namespace: "idp" }); - - return ( - -
-

{t("loginSuccess.title")}

-

{t("loginSuccess.description")}

- - -
-
- ); -} - -async function linkingSuccess( - userId: string, - idpIntent: { idpIntentId: string; idpIntentToken: string }, - authRequestId?: string, - branding?: BrandingSettings, -) { - const locale = getLocale(); - const t = await getTranslations({ locale, namespace: "idp" }); - - return ( - -
-

{t("linkingSuccess.title")}

-

{t("linkingSuccess.description")}

- - -
-
- ); -} - -async function linkingFailed(branding?: BrandingSettings) { - const locale = getLocale(); - const t = await getTranslations({ locale, namespace: "idp" }); - - return ( - -
-

{t("linkingError.title")}

-
- { - - {t("linkingError.description")} - - } -
-
-
- ); -} - export default async function Page(props: { searchParams: Promise>; params: Promise<{ provider: string }>; @@ -168,9 +81,13 @@ export default async function Page(props: { userName: idpInformation.userName, }, userId, - ); + ).catch((error) => { + console.error(error); + return linkingFailed(branding); + }); if (!idpLink) { + console.log("linking failed"); return linkingFailed(branding); } else { return linkingSuccess( @@ -217,10 +134,12 @@ export default async function Page(props: { }, foundUser.userId, ).catch((error) => { + console.error(error); return linkingFailed(branding); }); - - if (idpLink) { + if (!idpLink) { + return linkingFailed(branding); + } else { return linkingSuccess( foundUser.userId, { idpIntentId: id, idpIntentToken: token }, diff --git a/apps/login/src/app/error.tsx b/apps/login/src/app/error.tsx index bee6516a59..d475786620 100644 --- a/apps/login/src/app/error.tsx +++ b/apps/login/src/app/error.tsx @@ -2,6 +2,7 @@ import { Boundary } from "@/components/boundary"; import { Button } from "@/components/button"; +import { LanguageProvider } from "@/components/language-provider"; import { useTranslations } from "next-intl"; import { useEffect } from "react"; @@ -13,15 +14,17 @@ export default function Error({ error, reset }: any) { const t = useTranslations("error"); return ( - -
-
- Error: {error?.message} + + +
+
+ Error: {error?.message} +
+
+ +
-
- -
-
- + + ); } diff --git a/apps/login/src/components/idps/pages/linking-failed.tsx b/apps/login/src/components/idps/pages/linking-failed.tsx new file mode 100644 index 0000000000..94678fb293 --- /dev/null +++ b/apps/login/src/components/idps/pages/linking-failed.tsx @@ -0,0 +1,28 @@ +"use client"; + +import { LanguageProvider } from "@/components/language-provider"; +import { BrandingSettings } from "@zitadel/proto/zitadel/settings/v2/branding_settings_pb"; +import { useTranslations } from "next-intl"; +import { Alert, AlertType } from "../../alert"; +import { DynamicTheme } from "../../dynamic-theme"; + +export function linkingFailed(branding?: BrandingSettings) { + const t = useTranslations("idp"); + + return ( + + +
+

{t("linkingError.title")}

+
+ { + + {t("linkingError.description")} + + } +
+
+
+
+ ); +} diff --git a/apps/login/src/components/idps/pages/linking-success.tsx b/apps/login/src/components/idps/pages/linking-success.tsx new file mode 100644 index 0000000000..39671d8f60 --- /dev/null +++ b/apps/login/src/components/idps/pages/linking-success.tsx @@ -0,0 +1,30 @@ +"use client"; + +import { BrandingSettings } from "@zitadel/proto/zitadel/settings/v2/branding_settings_pb"; +import { useTranslations } from "next-intl"; +import { DynamicTheme } from "../../dynamic-theme"; +import { IdpSignin } from "../../idp-signin"; + +export function linkingSuccess( + userId: string, + idpIntent: { idpIntentId: string; idpIntentToken: string }, + authRequestId?: string, + branding?: BrandingSettings, +) { + const t = useTranslations("idp"); + + return ( + +
+

{t("linkingSuccess.title")}

+

{t("linkingSuccess.description")}

+ + +
+
+ ); +} diff --git a/apps/login/src/components/idps/pages/login-failed.tsx b/apps/login/src/components/idps/pages/login-failed.tsx new file mode 100644 index 0000000000..5bddf29a08 --- /dev/null +++ b/apps/login/src/components/idps/pages/login-failed.tsx @@ -0,0 +1,27 @@ +"use client"; + +import { LanguageProvider } from "@/components/language-provider"; +import { BrandingSettings } from "@zitadel/proto/zitadel/settings/v2/branding_settings_pb"; +import { useTranslations } from "next-intl"; +import { Alert, AlertType } from "../../alert"; +import { DynamicTheme } from "../../dynamic-theme"; + +export function loginFailed(branding?: BrandingSettings, error: string = "") { + const t = useTranslations("idp"); + + return ( + + +
+

{t("loginError.title")}

+

{t("loginError.description")}

+ {error && ( +
+ {{error}} +
+ )} +
+
+
+ ); +} diff --git a/apps/login/src/components/idps/pages/login-success.tsx b/apps/login/src/components/idps/pages/login-success.tsx new file mode 100644 index 0000000000..39aa71c642 --- /dev/null +++ b/apps/login/src/components/idps/pages/login-success.tsx @@ -0,0 +1,33 @@ +"use client"; + +import { LanguageProvider } from "@/components/language-provider"; +import { BrandingSettings } from "@zitadel/proto/zitadel/settings/v2/branding_settings_pb"; +import { useTranslations } from "next-intl"; +import { DynamicTheme } from "../../dynamic-theme"; +import { IdpSignin } from "../../idp-signin"; + +export function loginSuccess( + userId: string, + idpIntent: { idpIntentId: string; idpIntentToken: string }, + authRequestId?: string, + branding?: BrandingSettings, +) { + const t = useTranslations("idp"); + + return ( + + +
+

{t("loginSuccess.title")}

+

{t("loginSuccess.description")}

+ + +
+
+
+ ); +}