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'}
|
2023-01-23 10:29:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
arg: 'aclList',
|
|
|
|
type: 'Object',
|
|
|
|
required: true,
|
2022-12-27 08:05:50 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
returns: {
|
|
|
|
type: 'Object',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: '/user/acl',
|
2023-01-23 10:29:58 +00:00
|
|
|
verb: 'POST'
|
2022-12-27 08:05:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-01-23 10:29:58 +00:00
|
|
|
Self.userAcl = async function(ctx, aclList) {
|
2022-12-27 08:05:50 +00:00
|
|
|
let models = Self.app.models;
|
|
|
|
|
2023-01-23 10:29:58 +00:00
|
|
|
let ACLs = [];
|
|
|
|
|
|
|
|
for (let key in aclList) {
|
2023-02-03 10:46:33 +00:00
|
|
|
let acl = await models.ACL.findOne({
|
2023-01-23 10:29:58 +00:00
|
|
|
where: {
|
|
|
|
principalId: key,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (acl)
|
|
|
|
ACLs.push(acl);
|
|
|
|
}
|
|
|
|
return ACLs;
|
2022-12-27 08:05:50 +00:00
|
|
|
};
|
|
|
|
};
|