feat: refs #8304 add ACL entry for WorkerDms with high privileges #3353
|
@ -0,0 +1,6 @@
|
||||||
|
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
|
||||||
|
VALUES
|
||||||
|
('WorkerDms', 'hasHighPrivs', 'READ', 'ALLOW', 'ROLE', 'hr'),
|
||||||
|
('Business', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
|
||||||
|
('Worker', '__get__business', 'READ', 'ALLOW', 'ROLE', 'hr')
|
||||||
|
;
|
|
@ -13,6 +13,9 @@
|
||||||
},
|
},
|
||||||
"workcenterFk" : {
|
"workcenterFk" : {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"notes" : {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||||
const {mergeFilters, mergeWhere} = require('vn-loopback/util/filter');
|
const {mergeFilters, mergeWhere} = require('vn-loopback/util/filter');
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('filter', {
|
Self.remoteMethodCtx('filter', {
|
||||||
|
@ -33,7 +34,10 @@ module.exports = Self => {
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
const hasPrivs = await models.ACL.checkAccessAcl(ctx, 'WorkerDms', 'hasHighPrivs', '*');
|
||||||
|
|
||||||
|
if (!hasPrivs && userId !== id)
|
||||||
|
throw new UserError('You don\'t have enough privileges');
|
||||||
// Get ids alloweds
|
// Get ids alloweds
|
||||||
const account = await models.VnUser.findById(userId);
|
const account = await models.VnUser.findById(userId);
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,11 @@
|
||||||
"type": "hasMany",
|
"type": "hasMany",
|
||||||
"model": "WorkerRelative",
|
"model": "WorkerRelative",
|
||||||
"foreignKey": "workerFK"
|
"foreignKey": "workerFK"
|
||||||
|
},
|
||||||
|
"business": {
|
||||||
|
"type": "hasMany",
|
||||||
|
"model": "Business",
|
||||||
|
"foreignKey": "workerFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"acls": [
|
"acls": [
|
||||||
|
|
Loading…
Reference in New Issue