diff --git a/db/versions/11246-whiteMonstera/00-firstScript.sql b/db/versions/11246-whiteMonstera/00-firstScript.sql new file mode 100644 index 000000000..72c46cf79 --- /dev/null +++ b/db/versions/11246-whiteMonstera/00-firstScript.sql @@ -0,0 +1 @@ +DELETE FROM salix.ACL WHERE model = 'Worker' AND property = 'findById' AND principalId = 'employee'; \ No newline at end of file diff --git a/loopback/server/boot/role-resolver.js b/loopback/server/boot/role-resolver.js index cf70abb39..183d64de1 100644 --- a/loopback/server/boot/role-resolver.js +++ b/loopback/server/boot/role-resolver.js @@ -1,12 +1,9 @@ -const UserError = require('vn-loopback/util/user-error'); - module.exports = async function(app) { const models = app.models; models.VnRole.registerResolver('$subordinate', async(role, ctx) => { - Object.assign(ctx, {req: {accessToken: {userId: ctx.accessToken.userId}}}); - - const isSubordinate = await models.Worker.isSubordinate(ctx, +ctx.modelId); - if (!isSubordinate) throw new UserError(`You don't have enough privileges`); + if (!ctx.accessToken) return false; + const httpCtx = {req: {accessToken: {userId: ctx.accessToken.userId}}}; + return models.Worker.isSubordinate(httpCtx, +ctx.modelId); }); };