feat(user): add not authorized error message in permission check

This commit is contained in:
Ali BARIN
2024-11-08 13:46:40 +00:00
committed by Faruk AYDIN
parent f597066d16
commit da81ecf915
2 changed files with 4 additions and 2 deletions

View File

@@ -642,7 +642,7 @@ class User extends Base {
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);

View File

@@ -302,7 +302,9 @@ describe('User model', () => {
it('should throw an authorization error without Flow read permission', async () => {
const user = new User();
expect(() => user.authorizedFlows).toThrowError('NotAuthorized');
expect(() => user.authorizedFlows).toThrowError(
'The user is not authorized!'
);
});
});
});