@objectstack/plugin-auth 9.0.0 → 9.0.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
@@ -1099,16 +1099,19 @@ var AuthManager = class {
1099
1099
  });
1100
1100
  return (Array.isArray(members) ? members : []).some((m) => {
1101
1101
  const raw = typeof m?.role === "string" ? m.role : "";
1102
- const roles = raw.split(",").map((s) => s.trim().toLowerCase());
1103
- return roles.includes("owner") || roles.includes("admin");
1102
+ const roles2 = raw.split(",").map((s) => s.trim().toLowerCase());
1103
+ return roles2.includes("owner") || roles2.includes("admin");
1104
1104
  });
1105
1105
  } catch {
1106
1106
  return false;
1107
1107
  }
1108
1108
  };
1109
1109
  const promote = await isPlatformAdmin() || await isActiveOrgAdmin();
1110
- if (!promote) return { user, session };
1111
- return { user: { ...user, role: "admin" }, session };
1110
+ const storedRole = typeof user.role === "string" ? user.role : "";
1111
+ const roles = storedRole.split(",").map((s) => s.trim()).filter(Boolean);
1112
+ if (promote && !roles.includes("admin")) roles.push("admin");
1113
+ if (!promote) return { user: { ...user, roles }, session };
1114
+ return { user: { ...user, role: "admin", roles }, session };
1112
1115
  }));
1113
1116
  }
1114
1117
  return plugins;