CEC-464 can filters forms (#118)
* can filters forms and lists * unit tests * updating warnings and tests * merge develop * fixed snapshots * update jest mocks * updating tests
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
import { parsePayload } from "./jwt";
|
||||
|
||||
export const Roles = {
|
||||
CREATE: "efcc3025-e2d8-4212-8227-805c7be39d2c",
|
||||
READ: "a729bbd4-2038-4649-9127-16782bb1e701",
|
||||
CREATE: "efcc3025-e2d8-4212-8227-805c7be39d2c",
|
||||
DELETE: "8f78dce7-f5f9-4033-a10c-c9c7408bfcfe"
|
||||
}
|
||||
|
||||
export const hasRoleToken = (roles, token) => {
|
||||
if (!roles || roles.length === 0) return true;
|
||||
|
||||
|
||||
const groups = getGroups(token);
|
||||
|
||||
if (!groups) return false;
|
||||
|
||||
|
||||
return hasRole(roles, groups);
|
||||
}
|
||||
|
||||
@@ -26,7 +27,7 @@ export const getGroups = (token) => {
|
||||
export const hasRole = (roles, groups) => {
|
||||
if (!roles || roles.length === 0) return true;
|
||||
if (!groups) return false;
|
||||
|
||||
|
||||
for (let role of roles) {
|
||||
if (groups.indexOf(role) > -1) return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user