Skip to content

Commit

Permalink
fix: add validation in the user role guard (#854)
Browse files Browse the repository at this point in the history
* fix: add validation in the user role guard

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* fix: modify validation in the user role guard

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* fix: modify validation and error message changes in the user role guard

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

---------

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>
  • Loading branch information
KulkarniShashank authored and KulkarniShashank committed Sep 6, 2024
1 parent 63277f8 commit e57012b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/api-gateway/src/authz/guards/user-role.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ export class UserRoleGuard implements CanActivate {

const { user } = request;

if (user?.userRole && user?.userRole.includes('holder')) {
throw new ForbiddenException('This role is a holder.');
if (!user?.userRole) {
throw new ForbiddenException('This role is not a holder.');
}

if (!user?.userRole.includes('holder')) {
throw new ForbiddenException('This role is not a holder.');
}

return true;
Expand Down

0 comments on commit e57012b

Please sign in to comment.