Review fixes
This commit is contained in:
parent
361b03eb15
commit
befee78ce7
1 changed files with 6 additions and 9 deletions
|
@ -47,6 +47,12 @@ interface IsPermittedConfig {
|
||||||
rbacFlag: boolean;
|
rbacFlag: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const valueMatches = (regexp: string | undefined, val: string | undefined) => {
|
||||||
|
if (!val) return false;
|
||||||
|
if (!regexp) return true;
|
||||||
|
return new RegExp(regexp).test(val);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description it the logic behind depending on the roles whether a certain action
|
* @description it the logic behind depending on the roles whether a certain action
|
||||||
* is permitted or not the philosophy is inspired from Headless UI libraries where
|
* is permitted or not the philosophy is inspired from Headless UI libraries where
|
||||||
|
@ -94,15 +100,6 @@ export function isPermitted({
|
||||||
const resourcePermissions = clusterMap.get(resource);
|
const resourcePermissions = clusterMap.get(resource);
|
||||||
if (!resourcePermissions) return false;
|
if (!resourcePermissions) return false;
|
||||||
|
|
||||||
const valueMatches = (
|
|
||||||
regexp: string | undefined,
|
|
||||||
val: string | undefined
|
|
||||||
) => {
|
|
||||||
if (!val) return false;
|
|
||||||
if (!regexp) return true;
|
|
||||||
return new RegExp(regexp).test(val);
|
|
||||||
};
|
|
||||||
|
|
||||||
const actions = Array.isArray(action) ? action : [action];
|
const actions = Array.isArray(action) ? action : [action];
|
||||||
|
|
||||||
return actions.every((a) => {
|
return actions.every((a) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue