2022-10-31 13:13:06 +00:00
|
|
|
|
|
|
|
module.exports = function(app) {
|
2022-10-31 14:07:22 +00:00
|
|
|
app.models.ACL.checkAccessAcl = async(ctx, modelId, property, accessType = '*') => {
|
2022-10-31 13:13:06 +00:00
|
|
|
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';
|
|
|
|
};
|
|
|
|
};
|