refactor: separate function
This commit is contained in:
parent
05a959ee55
commit
42cce880cd
3 changed files with 7 additions and 7 deletions
|
|
@ -28,6 +28,7 @@ import {
|
|||
getUserRoles,
|
||||
removeUserRoles,
|
||||
} from "../services/keycloak";
|
||||
import { isSystem } from "../utils/keycloak";
|
||||
|
||||
if (!process.env.MINIO_BUCKET) {
|
||||
throw Error("Require MinIO bucket.");
|
||||
|
|
@ -36,9 +37,6 @@ if (!process.env.MINIO_BUCKET) {
|
|||
const MINIO_BUCKET = process.env.MINIO_BUCKET;
|
||||
const MANAGE_ROLES = ["system", "head_of_admin", "admin", "branch_manager"];
|
||||
|
||||
function isSystem(user: RequestWithUser["user"]) {
|
||||
return user.roles.includes("system");
|
||||
}
|
||||
function globalAllow(user: RequestWithUser["user"]) {
|
||||
const listAllowed = ["system", "head_of_admin"];
|
||||
return user.roles?.some((v) => listAllowed.includes(v)) || false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue