@objectstack/plugin-auth 6.8.0 → 6.9.0

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
@@ -873,14 +873,18 @@ var AuthManager = class {
873
873
  // never seed `sys_environment`) keep working: any lookup error
874
874
  // is treated as "no envs to protect".
875
875
  organizationHooks: {
876
- // Gate fresh organization creation behind `OS_MULTI_ORG_ENABLED`.
876
+ // Gate fresh organization creation behind the multi-org flag.
877
877
  // The plugin itself is always installed (so list/update/invite endpoints
878
878
  // keep responding); only the `create` operation is denied when the
879
- // deployment is provisioned in single-org mode. Default is enabled
880
- // to preserve historical behaviour.
879
+ // deployment is provisioned in single-org mode. Resolution order:
880
+ // 1. explicit `OS_MULTI_ORG_ENABLED` (wins for backwards compat),
881
+ // 2. else `OS_MULTI_TENANT` (multi-tenant deployments are always
882
+ // multi-org), default `'false'` → single-org / per-env runtime.
881
883
  beforeCreateOrganization: async () => {
884
+ const env = globalThis?.process?.env ?? {};
885
+ const explicit = env.OS_MULTI_ORG_ENABLED;
882
886
  const flag = String(
883
- globalThis?.process?.env?.OS_MULTI_ORG_ENABLED ?? "true"
887
+ explicit ?? env.OS_MULTI_TENANT ?? "false"
884
888
  ).toLowerCase();
885
889
  if (flag === "false") {
886
890
  const { APIError } = await import("better-auth/api");
@@ -1271,8 +1275,9 @@ var AuthManager = class {
1271
1275
  requireEmailVerification: emailPasswordConfig.requireEmailVerification ?? false
1272
1276
  };
1273
1277
  const pluginConfig = this.config.plugins ?? {};
1278
+ const multiOrgEnv = globalThis?.process?.env ?? {};
1274
1279
  const multiOrgEnabled = String(
1275
- globalThis?.process?.env?.OS_MULTI_ORG_ENABLED ?? "true"
1280
+ multiOrgEnv.OS_MULTI_ORG_ENABLED ?? multiOrgEnv.OS_MULTI_TENANT ?? "false"
1276
1281
  ).toLowerCase() !== "false";
1277
1282
  const DEFAULT_TERMS_URL = "https://objectstack.ai/terms";
1278
1283
  const DEFAULT_PRIVACY_URL = "https://objectstack.ai/privacy";