@modular-rest/server 1.13.1 → 1.13.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.
|
@@ -178,11 +178,11 @@ function _getPermissionList(db, collection, operationType) {
|
|
|
178
178
|
function checkAccess(db, collection, operationType, queryOrDoc, user) {
|
|
179
179
|
const permissionList = _getPermissionList(db, collection, operationType);
|
|
180
180
|
return permissionList.some(permission => {
|
|
181
|
-
if (permission.
|
|
181
|
+
if (permission.accessType === 'god_access')
|
|
182
182
|
return true;
|
|
183
|
-
if (permission.
|
|
183
|
+
if (permission.accessType === 'anonymous_access' && user.type === 'anonymous')
|
|
184
184
|
return true;
|
|
185
|
-
if (permission.
|
|
185
|
+
if (permission.accessType === 'user_access' && user.type === 'user')
|
|
186
186
|
return true;
|
|
187
187
|
return false;
|
|
188
188
|
});
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose, { Connection, Model, PopulateOptions, Query } from 'mongoose';
|
|
2
|
-
import { AccessTypes, AccessDefinition } from '../../class/security';
|
|
2
|
+
import { AccessTypes, AccessDefinition, Permission } from '../../class/security';
|
|
3
3
|
import triggerOperator from '../../class/trigger_operator';
|
|
4
4
|
import TypeCasters from './typeCasters';
|
|
5
5
|
import { config } from '../../config';
|
|
@@ -191,7 +191,7 @@ export function getCollection<T>(db: string, collection: string): Model<T> {
|
|
|
191
191
|
* @returns {any[]} List of permissions
|
|
192
192
|
* @private
|
|
193
193
|
*/
|
|
194
|
-
function _getPermissionList(db: string, collection: string, operationType: string):
|
|
194
|
+
function _getPermissionList(db: string, collection: string, operationType: string): Permission[] {
|
|
195
195
|
if (!permissionDefinitions[db] || !permissionDefinitions[db][collection]) {
|
|
196
196
|
return [];
|
|
197
197
|
}
|
|
@@ -224,9 +224,9 @@ export function checkAccess(
|
|
|
224
224
|
): boolean {
|
|
225
225
|
const permissionList = _getPermissionList(db, collection, operationType);
|
|
226
226
|
return permissionList.some(permission => {
|
|
227
|
-
if (permission.
|
|
228
|
-
if (permission.
|
|
229
|
-
if (permission.
|
|
227
|
+
if (permission.accessType === 'god_access') return true;
|
|
228
|
+
if (permission.accessType === 'anonymous_access' && user.type === 'anonymous') return true;
|
|
229
|
+
if (permission.accessType === 'user_access' && user.type === 'user') return true;
|
|
230
230
|
return false;
|
|
231
231
|
});
|
|
232
232
|
}
|