feat(user): add not authorized error message in permission check
This commit is contained in:
@@ -642,7 +642,7 @@ class User extends Base {
|
|||||||
can(action, subject) {
|
can(action, subject) {
|
||||||
const can = this.ability.can(action, subject);
|
const can = this.ability.can(action, subject);
|
||||||
|
|
||||||
if (!can) throw new NotAuthorizedError();
|
if (!can) throw new NotAuthorizedError(`The user is not authorized!`);
|
||||||
|
|
||||||
const relevantRule = this.ability.relevantRuleFor(action, subject);
|
const relevantRule = this.ability.relevantRuleFor(action, subject);
|
||||||
|
|
||||||
|
@@ -302,7 +302,9 @@ describe('User model', () => {
|
|||||||
it('should throw an authorization error without Flow read permission', async () => {
|
it('should throw an authorization error without Flow read permission', async () => {
|
||||||
const user = new User();
|
const user = new User();
|
||||||
|
|
||||||
expect(() => user.authorizedFlows).toThrowError('NotAuthorized');
|
expect(() => user.authorizedFlows).toThrowError(
|
||||||
|
'The user is not authorized!'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user