mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-13 16:00:02 +02:00
dont show servers idps in create user when idp mode is org on enterprise
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
import { db, idp, idpOrg, Transaction } from "@server/db";
|
import { db, idp, idpOrg, Transaction } from "@server/db";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
|
import { build } from "@server/build";
|
||||||
|
|
||||||
export function isOrgIdentityProviderMode(): boolean {
|
export function isOrgIdentityProviderMode(): boolean {
|
||||||
return process.env.IDENTITY_PROVIDER_MODE === "org";
|
return build === "saas" || process.env.IDENTITY_PROVIDER_MODE === "org";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { TierFeature, tierMatrix } from "@server/lib/billing/tierMatrix";
|
|||||||
import { assignUserToOrg } from "@server/lib/userOrg";
|
import { assignUserToOrg } from "@server/lib/userOrg";
|
||||||
import { isLicensedOrSubscribed } from "#dynamic/lib/isLicencedOrSubscribed";
|
import { isLicensedOrSubscribed } from "#dynamic/lib/isLicencedOrSubscribed";
|
||||||
import { isOrgRebuildRateLimited } from "@server/lib/rebuildClientAssociations";
|
import { isOrgRebuildRateLimited } from "@server/lib/rebuildClientAssociations";
|
||||||
|
import { idpExistsForOrg } from "@server/lib/idp/idpExistsForOrg";
|
||||||
|
|
||||||
const paramsSchema = z.strictObject({
|
const paramsSchema = z.strictObject({
|
||||||
orgId: z.string().nonempty()
|
orgId: z.string().nonempty()
|
||||||
@@ -239,6 +240,16 @@ export async function createOrgUser(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const providerExists = await idpExistsForOrg(idpId, orgId);
|
||||||
|
if (!providerExists) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
"Identity provider not found in this organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const [idpRes] = await db
|
const [idpRes] = await db
|
||||||
.select()
|
.select()
|
||||||
.from(idp)
|
.from(idp)
|
||||||
|
|||||||
@@ -237,10 +237,13 @@ export default function Page() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const useOrgIdps =
|
||||||
|
build === "saas" || env.app.identityProviderMode === "org";
|
||||||
|
|
||||||
const res = await api
|
const res = await api
|
||||||
.get<
|
.get<
|
||||||
AxiosResponse<ListIdpsResponse>
|
AxiosResponse<ListIdpsResponse>
|
||||||
>(build === "saas" ? `/org/${orgId}/idp` : "/idp")
|
>(useOrgIdps ? `/org/${orgId}/idp` : "/idp")
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
toast({
|
toast({
|
||||||
@@ -301,8 +304,7 @@ export default function Page() {
|
|||||||
);
|
);
|
||||||
const [isSubmittingExternal, setIsSubmittingExternal] = useState(false);
|
const [isSubmittingExternal, setIsSubmittingExternal] = useState(false);
|
||||||
|
|
||||||
const loading =
|
const loading = isSubmittingInternal || isSubmittingExternal;
|
||||||
isSubmittingInternal || isSubmittingExternal;
|
|
||||||
|
|
||||||
async function onSubmitInternal() {
|
async function onSubmitInternal() {
|
||||||
const isValid = await internalForm.trigger();
|
const isValid = await internalForm.trigger();
|
||||||
|
|||||||
Reference in New Issue
Block a user