salix/loopback/server/boot/role-resolver.js

10 lines
346 B
JavaScript

module.exports = async function(app) {
const models = app.models;
models.VnRole.registerResolver('$subordinate', async(role, ctx) => {
if (!ctx.accessToken) return false;
const httpCtx = {req: {accessToken: {userId: ctx.accessToken.userId}}};
return models.Worker.isSubordinate(httpCtx, +ctx.modelId);
});
};