@universis/janitor 2.5.0 → 2.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@universis/janitor",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "Universis api plugin for handling user authorization and rate limiting",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -87,6 +87,30 @@ class EnableReadAccessScope extends ApplicationService {
87
87
  }
88
88
  }
89
89
  }
90
+
91
+ // get views with scope based privileges
92
+ // noinspection JSUnresolvedReference
93
+ if (Array.isArray(definition.views)) {
94
+ // noinspection JSUnresolvedReference
95
+ const views = definition.views.filter((item) => {
96
+ return Array.isArray(item.privileges);
97
+ });
98
+ for (const view of views) {
99
+ const privileges = view.privileges.filter((privilege) => {
100
+ return privilege.mask === 1 && Array.isArray(privilege.scope) && privilege.scope.includes(searchScope);
101
+ });
102
+ if (privileges.length > 0) {
103
+ shouldUpdate = true;
104
+ for (const privilege of privileges) {
105
+ if (!privilege.scope.includes((targetScope))) {
106
+ privilege.scope.push(targetScope);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ }
112
+
113
+
90
114
  if (shouldUpdate) {
91
115
  updated++;
92
116
  // update model definition