Improve handling of checkUserRole (#5976)

This commit is contained in:
Oliver 2023-11-24 00:06:30 +11:00 committed by GitHub
parent a3f62c750e
commit b9424a9284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);