Fix permissions handling logic for admins/owners
This commit is contained in:
parent
8bc81c8c4b
commit
9347ee8d78
1 changed files with 16 additions and 11 deletions
|
@ -5,6 +5,12 @@ export const usePermissions = (action: string | string[]): boolean[] => {
|
|||
const userPermissions = ServerContext.useStoreState(state => state.server.permissions);
|
||||
|
||||
return useDeepMemo(() => {
|
||||
if (userPermissions[0] === '*') {
|
||||
return ([] as boolean[]).fill(
|
||||
true, 0, Array.isArray(action) ? action.length : 1,
|
||||
);
|
||||
}
|
||||
|
||||
return (Array.isArray(action) ? action : [ action ])
|
||||
.map(permission => (
|
||||
// Allows checking for any permission matching a name, for example files.*
|
||||
|
@ -16,7 +22,6 @@ export const usePermissions = (action: string | string[]): boolean[] => {
|
|||
) ||
|
||||
// Otherwise just check if the entire permission exists in the array or not.
|
||||
userPermissions.indexOf(permission) >= 0
|
||||
),
|
||||
);
|
||||
));
|
||||
}, [ action, userPermissions ]);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue