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";
|
} from "@zitadel/proto/zitadel/user/v2/user_service_pb";
|
||||||
import { getLocale, getTranslations } from "next-intl/server";
|
import { getLocale, getTranslations } from "next-intl/server";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
const ORG_SUFFIX_REGEX = /(?<=@)(.+)/;
|
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) {
|
if (addHumanUser) {
|
||||||
let addHumanUserWithOrganization: AddHumanUserRequest;
|
let addHumanUserWithOrganization: AddHumanUserRequest;
|
||||||
if (orgToRegisterOn) {
|
if (orgToRegisterOn) {
|
||||||
@@ -241,6 +243,16 @@ export default async function Page(props: {
|
|||||||
: "Could not create user",
|
: "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) {
|
if (newUser) {
|
||||||
|
@@ -7,6 +7,7 @@ import {
|
|||||||
getLegalAndSupportSettings,
|
getLegalAndSupportSettings,
|
||||||
getLoginSettings,
|
getLoginSettings,
|
||||||
getPasswordComplexitySettings,
|
getPasswordComplexitySettings,
|
||||||
|
retrieveIDPIntent,
|
||||||
} from "@/lib/zitadel";
|
} from "@/lib/zitadel";
|
||||||
import { Organization } from "@zitadel/proto/zitadel/org/v2/org_pb";
|
import { Organization } from "@zitadel/proto/zitadel/org/v2/org_pb";
|
||||||
import { getLocale, getTranslations } from "next-intl/server";
|
import { getLocale, getTranslations } from "next-intl/server";
|
||||||
@@ -19,7 +20,15 @@ export default async function Page(props: {
|
|||||||
const locale = getLocale();
|
const locale = getLocale();
|
||||||
const t = await getTranslations({ locale, namespace: "register" });
|
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 _headers = await headers();
|
||||||
const { serviceUrl } = getServiceUrlFromHeaders(_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({
|
const legal = await getLegalAndSupportSettings({
|
||||||
serviceUrl,
|
serviceUrl,
|
||||||
organization,
|
organization,
|
||||||
|
Reference in New Issue
Block a user