fix(org): allow internal organization creation when restricted for users

This commit is contained in:
Gautam Manchandani
2025-12-18 17:51:21 +05:30
parent 3897be5603
commit 6b31a4fece

View File

@@ -123,7 +123,9 @@ export const createOrganization = <O extends OrganizationOptions>(
? true
: options.allowUserToCreateOrganization;
if (!canCreateOrg) {
const isSystemAction = !session && ctx.body.userId;
if (!canCreateOrg && !isSystemAction) {
throw new APIError("FORBIDDEN", {
message:
ORGANIZATION_ERROR_CODES.YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION,