salix/back/methods/account/user-acl.js

36 lines
860 B
JavaScript
Raw Normal View History

2022-12-27 08:05:50 +00:00
module.exports = Self => {
Self.remoteMethod('userAcl', {
description: 'Get all of the current user permissions',
accepts: [
{
arg: 'ctx',
type: 'Object',
http: {source: 'context'}
},
{
arg: 'aclList',
type: 'Object',
required: true,
2022-12-27 08:05:50 +00:00
}
],
returns: {
type: 'Object',
root: true
},
http: {
path: '/user/acl',
verb: 'POST'
2022-12-27 08:05:50 +00:00
}
});
Self.userAcl = async function(ctx, aclList) {
2023-03-03 11:00:30 +00:00
const ACLs = [];
for (let key in aclList) {
2023-03-03 11:00:30 +00:00
const acl = await Self.app.models.ACL.findOne({where: {principalId: key}});
if (acl) ACLs.push(acl);
}
return ACLs;
2022-12-27 08:05:50 +00:00
};
};