@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.js CHANGED
@@ -1162,16 +1162,19 @@ var AuthManager = class {
1162
1162
  });
1163
1163
  return (Array.isArray(members) ? members : []).some((m) => {
1164
1164
  const raw = typeof m?.role === "string" ? m.role : "";
1165
- const roles = raw.split(",").map((s) => s.trim().toLowerCase());
1166
- return roles.includes("owner") || roles.includes("admin");
1165
+ const roles2 = raw.split(",").map((s) => s.trim().toLowerCase());
1166
+ return roles2.includes("owner") || roles2.includes("admin");
1167
1167
  });
1168
1168
  } catch {
1169
1169
  return false;
1170
1170
  }
1171
1171
  };
1172
1172
  const promote = await isPlatformAdmin() || await isActiveOrgAdmin();
1173
- if (!promote) return { user, session };
1174
- return { user: { ...user, role: "admin" }, session };
1173
+ const storedRole = typeof user.role === "string" ? user.role : "";
1174
+ const roles = storedRole.split(",").map((s) => s.trim()).filter(Boolean);
1175
+ if (promote && !roles.includes("admin")) roles.push("admin");
1176
+ if (!promote) return { user: { ...user, roles }, session };
1177
+ return { user: { ...user, role: "admin", roles }, session };
1175
1178
  }));
1176
1179
  }
1177
1180
  return plugins;