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 hasPermission = (role: Role | ProjectRole, hasRole: boolean, permission: Permission | string) => {
const rolePermission = rolePermissions[role] const rolePermission = rolePermissions[role]
return ( if (!hasRole || !rolePermission) return false
hasRole &&
rolePermission && if (isString(rolePermission) && rolePermission === '*') return true
((isString(rolePermission) && rolePermission === '*') || rolePermission[permission as keyof typeof rolePermission])
) return rolePermission[permission as keyof typeof rolePermission]
} }
const isUIAllowed = (permission: Permission | string, skipPreviewAs = false) => { const isUIAllowed = (permission: Permission | string, skipPreviewAs = false) => {

Loading…
Cancel
Save