feat: refs #8304 add ACL entry for WorkerDms with high privileges #3353

Open
jtubau wants to merge 7 commits from 8304-workerChangesAndFixes into dev
4 changed files with 19 additions and 1 deletions

View File

@ -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')
;

View File

@ -13,7 +13,10 @@
}, },
"workcenterFk" : { "workcenterFk" : {
"type": "number" "type": "number"
} },
"notes" : {
"type": "string"
}
}, },
"relations": { "relations": {
"worker": { "worker": {

View File

@ -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);

View File

@ -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": [