salix/loopback/server/boot/acl.js

23 lines
632 B
JavaScript
Raw Normal View History

2022-10-31 13:13:06 +00:00
module.exports = function(app) {
app.models.ACL.checkAccess = async(ctx, modelId, property, accessType = '*') => {
const models = app.models;
const context = {
accessToken: ctx.req.accessToken,
model: models[modelId],
property: property,
modelId: modelId,
accessType: accessType,
sharedMethod: {
name: property,
aliases: [],
sharedClass: true
}
};
const acl = await models.ACL.checkAccessForContext(context);
return acl.permission == 'ALLOW';
};
};