@7365admin1/core 3.46.1-staging.113 → 3.46.1-staging.114

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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Resolve the seeded platform staff role by type as well as name, so the default staff account cannot be bound to an ordinary organisation role that happens to share the name.
package/dist/index.d.ts CHANGED
@@ -282,7 +282,7 @@ declare function useRoleRepo(): {
282
282
  addRole: (value: TRole, session?: ClientSession) => Promise<ObjectId>;
283
283
  getRoleByUserId: (value: string | ObjectId) => Promise<TRole | null>;
284
284
  getRoleById: (_id: string | ObjectId) => Promise<TRole | null>;
285
- getRoleByName: (name: string) => Promise<TRole | null>;
285
+ getRoleByName: (name: string, type?: string) => Promise<TRole | null>;
286
286
  getRoles: ({ search, page, limit, sort, type, org, }: {
287
287
  search?: string | undefined;
288
288
  page?: number | undefined;
package/dist/index.js CHANGED
@@ -15957,18 +15957,19 @@ function useRoleRepo() {
15957
15957
  throw new import_node_server_utils33.InternalServerError("Failed to retrieve role by ID.");
15958
15958
  }
15959
15959
  }
15960
- async function getRoleByName(name) {
15960
+ async function getRoleByName(name, type) {
15961
15961
  if (!name) {
15962
15962
  throw new import_node_server_utils33.BadRequestError("Role name is required.");
15963
15963
  }
15964
+ const query2 = type ? { name, type } : { name };
15964
15965
  try {
15965
- const cacheKey = (0, import_node_server_utils33.makeCacheKey)(namespace_collection, { name });
15966
+ const cacheKey = (0, import_node_server_utils33.makeCacheKey)(namespace_collection, query2);
15966
15967
  const cachedData = await getCache(cacheKey);
15967
15968
  if (cachedData) {
15968
15969
  import_node_server_utils33.logger.info(`Cache hit for key: ${cacheKey}`);
15969
15970
  return cachedData;
15970
15971
  }
15971
- const data = await collection.findOne({ name });
15972
+ const data = await collection.findOne(query2);
15972
15973
  setCache(cacheKey, data, 15 * 60).then(() => {
15973
15974
  import_node_server_utils33.logger.info(`Cache set for key: ${cacheKey}`);
15974
15975
  }).catch((err) => {
@@ -16364,7 +16365,7 @@ function useUserService() {
16364
16365
  let role = "";
16365
16366
  const adminRole = "Super Admin";
16366
16367
  try {
16367
- const result = await getRoleByName(adminRole);
16368
+ const result = await getRoleByName(adminRole, "admin");
16368
16369
  if (result && result._id) {
16369
16370
  role = result._id?.toString();
16370
16371
  }