Skip to content

Commit

Permalink
NRPT-140: Fixes roles check. (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
marklise authored Jun 22, 2020
1 parent 8d959a9 commit c877301
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { JwtUtil } from '../utils/jwt-utils';
import { Observable } from 'rxjs';
import { ROLES } from '../../../../common/src/app/constants/auth';

declare let Keycloak: any;

Expand Down Expand Up @@ -113,7 +114,10 @@ export class KeycloakService {
return false;
}

return jwt.realm_access.roles.includes('sysadmin');
// Make sure they have at least one instance of including a role in the ROLE array
return ROLES.some(role => {
return jwt.realm_access.roles.includes(role);
});
}

/**
Expand Down
6 changes: 6 additions & 0 deletions angular/projects/common/src/app/constants/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const ROLES = [
'sysadmin',
'admin:lng',
'admin:nrced',
'admin:bcmi'
];

0 comments on commit c877301

Please sign in to comment.