23 lines
632 B
JavaScript
23 lines
632 B
JavaScript
|
|
||
|
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';
|
||
|
};
|
||
|
};
|