Browse Source

refactor(nc-gui): cancel permission check if prematurely caught

pull/3703/head
braks 2 years ago
parent
commit
4bd0dccc8d
  1. 10
      packages/nc-gui/composables/useUIPermission/index.ts

10
packages/nc-gui/composables/useUIPermission/index.ts

@ -12,11 +12,11 @@ const [setup, use] = useInjectionState(() => {
const hasPermission = (role: Role | ProjectRole, hasRole: boolean, permission: Permission | string) => {
const rolePermission = rolePermissions[role]
return (
hasRole &&
rolePermission &&
((isString(rolePermission) && rolePermission === '*') || rolePermission[permission as keyof typeof rolePermission])
)
if (!hasRole || !rolePermission) return false
if (isString(rolePermission) && rolePermission === '*') return true
return rolePermission[permission as keyof typeof rolePermission]
}
const isUIAllowed = (permission: Permission | string, skipPreviewAs = false) => {

Loading…
Cancel
Save