mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improve handling of checkUserRole (#5976)
This commit is contained in:
parent
a3f62c750e
commit
b9424a9284
@ -83,8 +83,9 @@ export const useUserState = create<UserStateProps>((set, get) => ({
|
||||
if (user?.is_superuser) return true;
|
||||
if (user?.roles === undefined) return false;
|
||||
if (user?.roles[role] === undefined) return false;
|
||||
if (user?.roles[role] === null) return false;
|
||||
|
||||
return user?.roles[role].includes(permission);
|
||||
return user?.roles[role]?.includes(permission) ?? false;
|
||||
},
|
||||
hasDeleteRole: (role: UserRoles) => {
|
||||
return get().checkUserRole(role, UserPermissions.delete);
|
||||
|
Loading…
Reference in New Issue
Block a user