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 1cee8b587c..cf5f0c8637 100644 --- a/apps/login/src/app/(login)/idp/[provider]/success/page.tsx +++ b/apps/login/src/app/(login)/idp/[provider]/success/page.tsx @@ -24,6 +24,7 @@ import { } from "@zitadel/proto/zitadel/user/v2/user_service_pb"; import { getLocale, getTranslations } from "next-intl/server"; import { headers } from "next/headers"; +import { redirect } from "next/navigation"; const ORG_SUFFIX_REGEX = /(?<=@)(.+)/; @@ -205,6 +206,7 @@ export default async function Page(props: { } } + // if addHumanUser is provided in the intent, expect that it can be created otherwise show an error if (addHumanUser) { let addHumanUserWithOrganization: AddHumanUserRequest; if (orgToRegisterOn) { @@ -241,6 +243,16 @@ export default async function Page(props: { : "Could not create user", ); } + } else { + // if no user was found, we will create a new user manually / redirect to the registration page + if (options.isCreationAllowed) { + const registerParams = new URLSearchParams({ + idpIntentId: id, + idpIntentToken: token, + organization: organization ?? "", + }); + return redirect(`/register?${registerParams})}`); + } } if (newUser) { diff --git a/apps/login/src/app/(login)/register/page.tsx b/apps/login/src/app/(login)/register/page.tsx index e50511edb1..d042b52c60 100644 --- a/apps/login/src/app/(login)/register/page.tsx +++ b/apps/login/src/app/(login)/register/page.tsx @@ -7,6 +7,7 @@ import { getLegalAndSupportSettings, getLoginSettings, getPasswordComplexitySettings, + retrieveIDPIntent, } from "@/lib/zitadel"; import { Organization } from "@zitadel/proto/zitadel/org/v2/org_pb"; import { getLocale, getTranslations } from "next-intl/server"; @@ -19,7 +20,15 @@ export default async function Page(props: { const locale = getLocale(); const t = await getTranslations({ locale, namespace: "register" }); - let { firstname, lastname, email, organization, requestId } = searchParams; + let { + firstname, + lastname, + email, + organization, + requestId, + idpIntentId, + idpIntentToken, + } = searchParams; const _headers = await headers(); const { serviceUrl } = getServiceUrlFromHeaders(_headers); @@ -33,6 +42,17 @@ export default async function Page(props: { } } + let idpIntent; + if (idpIntentId && idpIntentToken) { + idpIntent = await retrieveIDPIntent({ + serviceUrl, + id: idpIntentId, + token: idpIntentToken, + }); + + const { idpInformation, userId } = idpIntent; + } + const legal = await getLegalAndSupportSettings({ serviceUrl, organization,