user can only change roles and delete users with roles below his role
parent
ce692dc5a0
commit
8b6f59b0f0
|
@ -73,7 +73,16 @@ export default function AllUsers() {
|
|||
{hasPermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ALL_USERS.ACTION.CHANGE_ROLE
|
||||
) && (
|
||||
) &&
|
||||
(webSocketContext.AllRoles.find(
|
||||
(role) => role.Id === webSocketContext.User.RoleId
|
||||
).SortingOrder <
|
||||
webSocketContext.AllRoles.find(
|
||||
(role) => role.Id === record._roleId
|
||||
).SortingOrder ||
|
||||
webSocketContext.AllRoles.find(
|
||||
(role) => role.Id === webSocketContext.User.RoleId
|
||||
).Master) && (
|
||||
<Popconfirm
|
||||
title="Change role to"
|
||||
okText="Change"
|
||||
|
@ -97,11 +106,24 @@ export default function AllUsers() {
|
|||
value={selectedRoleId}
|
||||
onChange={(e) => setSelectedRoleId(e)}
|
||||
>
|
||||
{webSocketContext.AllRoles.map((role) => (
|
||||
{webSocketContext.AllRoles.map((role) => {
|
||||
if (
|
||||
webSocketContext.AllRoles.find(
|
||||
(role) => role.Id === webSocketContext.User.RoleId
|
||||
).Master ||
|
||||
webSocketContext.AllRoles.find(
|
||||
(role) => role.Id === webSocketContext.User.RoleId
|
||||
).SortingOrder < role.SortingOrder
|
||||
) {
|
||||
return (
|
||||
<Select.Option key={role.Id}>
|
||||
{role.DisplayName}
|
||||
</Select.Option>
|
||||
))}
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
})}
|
||||
</Select>
|
||||
}
|
||||
>
|
||||
|
@ -120,27 +142,19 @@ export default function AllUsers() {
|
|||
</Popconfirm>
|
||||
)}
|
||||
|
||||
{console.log(
|
||||
webSocketContext.User.RoleId,
|
||||
webSocketContext.AllRoles.find(
|
||||
(role) => role.Id === webSocketContext.User.RoleId
|
||||
).SortingOrder,
|
||||
|
||||
webSocketContext.AllRoles.find(
|
||||
(role) => role.Id === record._roleId
|
||||
).SortingOrder
|
||||
)}
|
||||
|
||||
{hasPermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ALL_USERS.ACTION.DELETE_USER
|
||||
) &&
|
||||
webSocketContext.AllRoles.find(
|
||||
(webSocketContext.AllRoles.find(
|
||||
(role) => role.Id === webSocketContext.User.RoleId
|
||||
).SortingOrder <
|
||||
webSocketContext.AllRoles.find(
|
||||
(role) => role.Id === record._roleId
|
||||
).SortingOrder && (
|
||||
).SortingOrder ||
|
||||
webSocketContext.AllRoles.find(
|
||||
(role) => role.Id === webSocketContext.User.RoleId
|
||||
).Master) && (
|
||||
<Popconfirm
|
||||
placement="top"
|
||||
okText="Delete user"
|
||||
|
|
Loading…
Reference in New Issue