fix: use default org if no context detected

This commit is contained in:
Max Peintner
2025-04-24 10:58:53 +02:00
parent 830c2795e9
commit b5d42a0ac2

View File

@@ -4,7 +4,6 @@ import { linkingFailed } from "@/components/idps/pages/linking-failed";
import { linkingSuccess } from "@/components/idps/pages/linking-success"; import { linkingSuccess } from "@/components/idps/pages/linking-success";
import { loginFailed } from "@/components/idps/pages/login-failed"; import { loginFailed } from "@/components/idps/pages/login-failed";
import { loginSuccess } from "@/components/idps/pages/login-success"; import { loginSuccess } from "@/components/idps/pages/login-success";
import { idpTypeToIdentityProviderType } from "@/lib/idp";
import { getServiceUrlFromHeaders } from "@/lib/service"; import { getServiceUrlFromHeaders } from "@/lib/service";
import { import {
addHuman, addHuman,
@@ -19,7 +18,10 @@ import {
import { create } from "@zitadel/client"; import { create } from "@zitadel/client";
import { AutoLinkingOption } from "@zitadel/proto/zitadel/idp/v2/idp_pb"; import { AutoLinkingOption } from "@zitadel/proto/zitadel/idp/v2/idp_pb";
import { OrganizationSchema } from "@zitadel/proto/zitadel/object/v2/object_pb"; import { OrganizationSchema } from "@zitadel/proto/zitadel/object/v2/object_pb";
import { AddHumanUserRequestSchema } from "@zitadel/proto/zitadel/user/v2/user_service_pb"; import {
AddHumanUserRequest,
AddHumanUserRequestSchema,
} 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";
@@ -83,8 +85,6 @@ export default async function Page(props: {
throw new Error("IDP not found"); throw new Error("IDP not found");
} }
const providerType = idpTypeToIdentityProviderType(idp.type);
if (link) { if (link) {
if (!options?.isLinkingAllowed) { if (!options?.isLinkingAllowed) {
// linking was probably disallowed since the invitation was created // linking was probably disallowed since the invitation was created
@@ -205,15 +205,23 @@ export default async function Page(props: {
} }
} }
if (addHumanUser && orgToRegisterOn) { if (addHumanUser) {
let addHumanUserWithOrganization: AddHumanUserRequest;
if (orgToRegisterOn) {
const organizationSchema = create(OrganizationSchema, { const organizationSchema = create(OrganizationSchema, {
org: { case: "orgId", value: orgToRegisterOn }, org: { case: "orgId", value: orgToRegisterOn },
}); });
const addHumanUserWithOrganization = create(AddHumanUserRequestSchema, { addHumanUserWithOrganization = create(AddHumanUserRequestSchema, {
...addHumanUser, ...addHumanUser,
organization: organizationSchema, organization: organizationSchema,
}); });
} else {
addHumanUserWithOrganization = create(
AddHumanUserRequestSchema,
addHumanUser,
);
}
newUser = await addHuman({ newUser = await addHuman({
serviceUrl, serviceUrl,