mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 15:07:32 +00:00
register with idp intent
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user