aloux-iam 0.0.144 → 0.0.145
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/lib/middleware.js +4 -6
- package/package.json +1 -1
package/lib/middleware.js
CHANGED
|
@@ -4,15 +4,13 @@ const Permission = require("./models/Permission");
|
|
|
4
4
|
const historyController = require("./controllers/history");
|
|
5
5
|
|
|
6
6
|
const getAccess = (user, resource) => {
|
|
7
|
-
// Cuenta de servicio
|
|
7
|
+
// Cuenta de servicio: verifica acceso por api asignada
|
|
8
8
|
const userApis = user?.data?.apis || [];
|
|
9
|
-
if (userApis.
|
|
10
|
-
return
|
|
11
|
-
(apiId) => apiId.toString() === resource._id.toString(),
|
|
12
|
-
);
|
|
9
|
+
if (userApis.some((apiId) => apiId.toString() === resource._id.toString())) {
|
|
10
|
+
return true;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
// Flujo normal
|
|
13
|
+
// Flujo normal: verifica permisos por función/rol
|
|
16
14
|
for (let i in user._functions) {
|
|
17
15
|
for (let j in user._functions[i]._permissions) {
|
|
18
16
|
if (user._functions[i]._permissions[j].status === "Activo") {
|