From c2be3e7260668817849698b0e8f7d082d18f36c4 Mon Sep 17 00:00:00 2001 From: Daniil Palagin Date: Mon, 7 Oct 2024 11:50:36 +0200 Subject: [PATCH] [#202] Refactor SecurityUtils --- src/utils/SecurityUtils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/SecurityUtils.js b/src/utils/SecurityUtils.js index f04eeb3..5826bd8 100644 --- a/src/utils/SecurityUtils.js +++ b/src/utils/SecurityUtils.js @@ -24,9 +24,9 @@ export function hasRole(user, role) { return user.roles ? user.roles.includes(role) : false; } -export function isImpersonator(currentUser) { +export function isImpersonator(user) { // When using OIDC, the access token does not contain any info that the current user is being impersonated - return !isUsingOidcAuth() && sanitizeArray(currentUser.types).indexOf(IMPERSONATOR_TYPE) !== -1; + return !isUsingOidcAuth() && user.roles.includes(ROLE.IMPERSONATE); } export function getRoles(user) { @@ -36,6 +36,6 @@ export function getRoles(user) { return user.roleGroup.roles; } -function isRoleExist(role) { +function roleExists(role) { return Object.values(ROLE).includes(role); }