fix: update permission logic to ensure administrators always have access (#17360)
This commit is contained in:
parent
78409dfec1
commit
e2b8f40275
1 changed files with 5 additions and 1 deletions
|
|
@ -5,15 +5,19 @@ import { useTranslation } from 'react-i18next'
|
||||||
import { useInvalidatePermissions, useMutationPermissions, usePermissions } from '@/service/use-plugins'
|
import { useInvalidatePermissions, useMutationPermissions, usePermissions } from '@/service/use-plugins'
|
||||||
|
|
||||||
const hasPermission = (permission: PermissionType | undefined, isAdmin: boolean) => {
|
const hasPermission = (permission: PermissionType | undefined, isAdmin: boolean) => {
|
||||||
|
if (isAdmin)
|
||||||
|
return true // Administrators always have permissions
|
||||||
|
|
||||||
if (!permission)
|
if (!permission)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if (permission === PermissionType.noOne)
|
if (permission === PermissionType.noOne)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if (permission === PermissionType.everyone)
|
if (permission === PermissionType.everyone)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
return isAdmin
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const usePermission = () => {
|
const usePermission = () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue