mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-06 22:58:09 -05:00
fix: disallow admins to edit other admins in bulk edit (#1340)
This PR fixes a bug where admin users could edit the permissions of other admins in the bulk edit modal. fix #1309
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import Modal from '@app/components/Common/Modal';
|
import Modal from '@app/components/Common/Modal';
|
||||||
import PermissionEdit from '@app/components/PermissionEdit';
|
import PermissionEdit from '@app/components/PermissionEdit';
|
||||||
import type { User } from '@app/hooks/useUser';
|
import type { User } from '@app/hooks/useUser';
|
||||||
import { useUser } from '@app/hooks/useUser';
|
import { Permission, useUser } from '@app/hooks/useUser';
|
||||||
import globalMessages from '@app/i18n/globalMessages';
|
import globalMessages from '@app/i18n/globalMessages';
|
||||||
import defineMessages from '@app/utils/defineMessages';
|
import defineMessages from '@app/utils/defineMessages';
|
||||||
|
import { hasPermission } from '@server/lib/permissions';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import { useToasts } from 'react-toast-notifications';
|
import { useToasts } from 'react-toast-notifications';
|
||||||
@@ -79,7 +80,10 @@ const BulkEditModal = ({
|
|||||||
const { permissions: allPermissionsEqual } = selectedUsers.reduce(
|
const { permissions: allPermissionsEqual } = selectedUsers.reduce(
|
||||||
({ permissions: aPerms }, { permissions: bPerms }) => {
|
({ permissions: aPerms }, { permissions: bPerms }) => {
|
||||||
return {
|
return {
|
||||||
permissions: aPerms === bPerms ? aPerms : NaN,
|
permissions:
|
||||||
|
aPerms === bPerms || hasPermission(Permission.ADMIN, aPerms)
|
||||||
|
? aPerms
|
||||||
|
: NaN,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{ permissions: selectedUsers[0].permissions }
|
{ permissions: selectedUsers[0].permissions }
|
||||||
|
|||||||
Reference in New Issue
Block a user