@aptly-as/express-scope 1.2.0 → 1.2.2
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/Scope.js +4 -4
- package/package.json +1 -1
package/lib/Scope.js
CHANGED
|
@@ -71,7 +71,7 @@ export class Scope {
|
|
|
71
71
|
try {
|
|
72
72
|
const { user, organization, modules, override, extend } = this._scopeAccess(req);
|
|
73
73
|
if (override) {
|
|
74
|
-
return res.json(override);
|
|
74
|
+
return action === 'return' ? override : res.json(override);
|
|
75
75
|
}
|
|
76
76
|
let json = this._scopes.reduce((obj, modelKey) => {
|
|
77
77
|
const userPermission = new Set(this._getScopeArray(user, this._userRoles, modelKey));
|
|
@@ -135,6 +135,9 @@ export class Scope {
|
|
|
135
135
|
}
|
|
136
136
|
_checkScope(req, scopes, access) {
|
|
137
137
|
const { user, organization, modules, override, extend } = this._scopeAccess(req);
|
|
138
|
+
if (extend && scopes.some((mod) => extend[mod] && extend[mod].includes(access))) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
138
141
|
if (modules &&
|
|
139
142
|
!modules.some((module) => scopes.some((scope) => this._modules[module]?.includes(scope)))) {
|
|
140
143
|
return false;
|
|
@@ -148,9 +151,6 @@ export class Scope {
|
|
|
148
151
|
if (organization?.some((org) => scopes.some((mod) => this._organizationRoles[org]?.[mod]?.includes(access)))) {
|
|
149
152
|
return true;
|
|
150
153
|
}
|
|
151
|
-
if (extend) {
|
|
152
|
-
return scopes.some((mod) => extend[mod] && extend[mod].includes(access));
|
|
153
|
-
}
|
|
154
154
|
return false;
|
|
155
155
|
}
|
|
156
156
|
_getObjects(obj) {
|