@objectstack/plugin-auth 6.7.0 → 6.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -830,6 +830,22 @@ var AuthManager = class {
830
830
  // never seed `sys_environment`) keep working: any lookup error
831
831
  // is treated as "no envs to protect".
832
832
  organizationHooks: {
833
+ // Gate fresh organization creation behind `OS_MULTI_ORG_ENABLED`.
834
+ // The plugin itself is always installed (so list/update/invite endpoints
835
+ // keep responding); only the `create` operation is denied when the
836
+ // deployment is provisioned in single-org mode. Default is enabled
837
+ // to preserve historical behaviour.
838
+ beforeCreateOrganization: async () => {
839
+ const flag = String(
840
+ globalThis?.process?.env?.OS_MULTI_ORG_ENABLED ?? "true"
841
+ ).toLowerCase();
842
+ if (flag === "false") {
843
+ const { APIError } = await import("better-auth/api");
844
+ throw new APIError("FORBIDDEN", {
845
+ message: "Creating additional organizations is disabled on this deployment."
846
+ });
847
+ }
848
+ },
833
849
  beforeUpdateOrganization: async ({ organization: organization2, member }) => {
834
850
  const newSlug = organization2?.slug;
835
851
  const orgId = member?.organizationId;
@@ -1210,11 +1226,15 @@ var AuthManager = class {
1210
1226
  requireEmailVerification: emailPasswordConfig.requireEmailVerification ?? false
1211
1227
  };
1212
1228
  const pluginConfig = this.config.plugins ?? {};
1229
+ const multiOrgEnabled = String(
1230
+ globalThis?.process?.env?.OS_MULTI_ORG_ENABLED ?? "true"
1231
+ ).toLowerCase() !== "false";
1213
1232
  const features = {
1214
1233
  twoFactor: pluginConfig.twoFactor ?? false,
1215
1234
  passkeys: pluginConfig.passkeys ?? false,
1216
1235
  magicLink: pluginConfig.magicLink ?? false,
1217
1236
  organization: pluginConfig.organization ?? true,
1237
+ multiOrgEnabled,
1218
1238
  oidcProvider: pluginConfig.oidcProvider ?? false,
1219
1239
  deviceAuthorization: pluginConfig.deviceAuthorization ?? false
1220
1240
  };