strapi-custom-auth 1.2.12 → 1.2.14
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/server/index.js +12 -7
- package/dist/server/index.mjs +12 -7
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -39333,7 +39333,7 @@ var oauth = ({ strapi: strapi2 }) => ({
|
|
|
39333
39333
|
${storage}.setItem('userInfo', '${JSON.stringify(user)}');
|
|
39334
39334
|
${storage}.setItem('refreshToken', '"${refreshToken}"');
|
|
39335
39335
|
${storage}.setItem('provider', '${provider}');
|
|
39336
|
-
location.href = '${strapi2.config.admin.url}'
|
|
39336
|
+
location.href = '${strapi2.config.admin.url}?redirectedFrom=plugin'
|
|
39337
39337
|
})
|
|
39338
39338
|
<\/script>
|
|
39339
39339
|
</head>
|
|
@@ -39428,14 +39428,14 @@ var role = ({ strapi: strapi2 }) => ({
|
|
|
39428
39428
|
},
|
|
39429
39429
|
async retrieveMicrosoftUserRoles(groupList, config2) {
|
|
39430
39430
|
const allowedGroups = /* @__PURE__ */ new Set([
|
|
39431
|
-
String(config2["ENTRA_ADMIN_GROUP_NAME"]),
|
|
39432
|
-
String(config2["ENTRA_EDITOR_GROUP_NAME"])
|
|
39431
|
+
String(config2["ENTRA_ADMIN_GROUP_NAME"]).toLowerCase(),
|
|
39432
|
+
String(config2["ENTRA_EDITOR_GROUP_NAME"]).toLowerCase()
|
|
39433
39433
|
]);
|
|
39434
|
-
const filteredGroups = groupList.filter((group) => allowedGroups.has(group.displayName));
|
|
39434
|
+
const filteredGroups = groupList.filter((group) => allowedGroups.has(group.displayName.toLowerCase()));
|
|
39435
39435
|
const dbRoles = await strapi2.db.query("admin::role").findMany();
|
|
39436
39436
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback USER strapi roles list", dbRoles);
|
|
39437
39437
|
const roles2 = filteredGroups.map((group) => {
|
|
39438
|
-
const roleName = group.displayName.includes("
|
|
39438
|
+
const roleName = group.displayName.toLowerCase().includes("admin") ? "admin" : "editor";
|
|
39439
39439
|
return dbRoles.find((role2) => role2.name.toLowerCase().includes(roleName))?.id;
|
|
39440
39440
|
}).filter(Boolean);
|
|
39441
39441
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback USER strapi roles matched with entra groups", roles2);
|
|
@@ -39448,7 +39448,9 @@ var role = ({ strapi: strapi2 }) => ({
|
|
|
39448
39448
|
const userCurrentRoles = user.roles.map((role2) => role2.id) || [];
|
|
39449
39449
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback checkMicrosoftUserRolesMismatch: User current roles", userCurrentRoles);
|
|
39450
39450
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback checkMicrosoftUserRolesMismatch: END");
|
|
39451
|
-
|
|
39451
|
+
const rolesToAdd = entraMatchedRoles.filter((roleId) => !userCurrentRoles.includes(roleId));
|
|
39452
|
+
const rolesToRemove = userCurrentRoles.filter((roleId) => !entraMatchedRoles.includes(roleId));
|
|
39453
|
+
return rolesToAdd.length > 0 || rolesToRemove.length > 0;
|
|
39452
39454
|
},
|
|
39453
39455
|
async updateMicrosoftUserRoles(user, groupList, config2) {
|
|
39454
39456
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback updateMicrosoftUserRoles: START");
|
|
@@ -39456,8 +39458,11 @@ var role = ({ strapi: strapi2 }) => ({
|
|
|
39456
39458
|
const entraMatchedRoles = await this.retrieveMicrosoftUserRoles(groupList, config2);
|
|
39457
39459
|
const userCurrentRoles = user.roles.map((role2) => role2.id) || [];
|
|
39458
39460
|
const rolesToAdd = entraMatchedRoles.filter((roleId) => !userCurrentRoles.includes(roleId));
|
|
39461
|
+
const rolesToRemove = userCurrentRoles.filter((roleId) => !entraMatchedRoles.includes(roleId));
|
|
39459
39462
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback updateMicrosoftUserRoles: Roles to add ->", rolesToAdd);
|
|
39460
|
-
|
|
39463
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback updateMicrosoftUserRoles: Roles to remove ->", rolesToRemove);
|
|
39464
|
+
const updatedRoles = [...userCurrentRoles, ...rolesToAdd].filter((roleId) => !rolesToRemove.includes(roleId));
|
|
39465
|
+
await userService.updateById(user.id, { roles: updatedRoles });
|
|
39461
39466
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback updateMicrosoftUserRoles: Updated user roles");
|
|
39462
39467
|
const updatedUser = await userService.findOne(user.id);
|
|
39463
39468
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback updateMicrosoftUserRoles: END");
|
package/dist/server/index.mjs
CHANGED
|
@@ -39318,7 +39318,7 @@ var oauth = ({ strapi: strapi2 }) => ({
|
|
|
39318
39318
|
${storage}.setItem('userInfo', '${JSON.stringify(user)}');
|
|
39319
39319
|
${storage}.setItem('refreshToken', '"${refreshToken}"');
|
|
39320
39320
|
${storage}.setItem('provider', '${provider}');
|
|
39321
|
-
location.href = '${strapi2.config.admin.url}'
|
|
39321
|
+
location.href = '${strapi2.config.admin.url}?redirectedFrom=plugin'
|
|
39322
39322
|
})
|
|
39323
39323
|
<\/script>
|
|
39324
39324
|
</head>
|
|
@@ -39413,14 +39413,14 @@ var role = ({ strapi: strapi2 }) => ({
|
|
|
39413
39413
|
},
|
|
39414
39414
|
async retrieveMicrosoftUserRoles(groupList, config2) {
|
|
39415
39415
|
const allowedGroups = /* @__PURE__ */ new Set([
|
|
39416
|
-
String(config2["ENTRA_ADMIN_GROUP_NAME"]),
|
|
39417
|
-
String(config2["ENTRA_EDITOR_GROUP_NAME"])
|
|
39416
|
+
String(config2["ENTRA_ADMIN_GROUP_NAME"]).toLowerCase(),
|
|
39417
|
+
String(config2["ENTRA_EDITOR_GROUP_NAME"]).toLowerCase()
|
|
39418
39418
|
]);
|
|
39419
|
-
const filteredGroups = groupList.filter((group) => allowedGroups.has(group.displayName));
|
|
39419
|
+
const filteredGroups = groupList.filter((group) => allowedGroups.has(group.displayName.toLowerCase()));
|
|
39420
39420
|
const dbRoles = await strapi2.db.query("admin::role").findMany();
|
|
39421
39421
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback USER strapi roles list", dbRoles);
|
|
39422
39422
|
const roles2 = filteredGroups.map((group) => {
|
|
39423
|
-
const roleName = group.displayName.includes("
|
|
39423
|
+
const roleName = group.displayName.toLowerCase().includes("admin") ? "admin" : "editor";
|
|
39424
39424
|
return dbRoles.find((role2) => role2.name.toLowerCase().includes(roleName))?.id;
|
|
39425
39425
|
}).filter(Boolean);
|
|
39426
39426
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback USER strapi roles matched with entra groups", roles2);
|
|
@@ -39433,7 +39433,9 @@ var role = ({ strapi: strapi2 }) => ({
|
|
|
39433
39433
|
const userCurrentRoles = user.roles.map((role2) => role2.id) || [];
|
|
39434
39434
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback checkMicrosoftUserRolesMismatch: User current roles", userCurrentRoles);
|
|
39435
39435
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback checkMicrosoftUserRolesMismatch: END");
|
|
39436
|
-
|
|
39436
|
+
const rolesToAdd = entraMatchedRoles.filter((roleId) => !userCurrentRoles.includes(roleId));
|
|
39437
|
+
const rolesToRemove = userCurrentRoles.filter((roleId) => !entraMatchedRoles.includes(roleId));
|
|
39438
|
+
return rolesToAdd.length > 0 || rolesToRemove.length > 0;
|
|
39437
39439
|
},
|
|
39438
39440
|
async updateMicrosoftUserRoles(user, groupList, config2) {
|
|
39439
39441
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback updateMicrosoftUserRoles: START");
|
|
@@ -39441,8 +39443,11 @@ var role = ({ strapi: strapi2 }) => ({
|
|
|
39441
39443
|
const entraMatchedRoles = await this.retrieveMicrosoftUserRoles(groupList, config2);
|
|
39442
39444
|
const userCurrentRoles = user.roles.map((role2) => role2.id) || [];
|
|
39443
39445
|
const rolesToAdd = entraMatchedRoles.filter((roleId) => !userCurrentRoles.includes(roleId));
|
|
39446
|
+
const rolesToRemove = userCurrentRoles.filter((roleId) => !entraMatchedRoles.includes(roleId));
|
|
39444
39447
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback updateMicrosoftUserRoles: Roles to add ->", rolesToAdd);
|
|
39445
|
-
|
|
39448
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback updateMicrosoftUserRoles: Roles to remove ->", rolesToRemove);
|
|
39449
|
+
const updatedRoles = [...userCurrentRoles, ...rolesToAdd].filter((roleId) => !rolesToRemove.includes(roleId));
|
|
39450
|
+
await userService.updateById(user.id, { roles: updatedRoles });
|
|
39446
39451
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback updateMicrosoftUserRoles: Updated user roles");
|
|
39447
39452
|
const updatedUser = await userService.findOne(user.id);
|
|
39448
39453
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback updateMicrosoftUserRoles: END");
|
package/package.json
CHANGED