feat: admins can't edit/delete other admins
This commit is contained in:
parent
41b766216e
commit
940b844857
2 changed files with 10 additions and 6 deletions
|
@ -109,13 +109,16 @@ export default function Users() {
|
|||
</Group>
|
||||
<Group position='right'>
|
||||
{user.administrator ? null : (
|
||||
<ActionIcon aria-label='delete' onClick={() => {setEditOpen(true); setSelectedUser(user);}}>
|
||||
<PencilIcon />
|
||||
</ActionIcon>
|
||||
<>
|
||||
<ActionIcon aria-label='edit' onClick={() => {setEditOpen(true); setSelectedUser(user);}}>
|
||||
<PencilIcon />
|
||||
</ActionIcon>
|
||||
<ActionIcon aria-label='delete' onClick={() => openDeleteModal(user)}>
|
||||
<DeleteIcon />
|
||||
</ActionIcon>
|
||||
</>
|
||||
)}
|
||||
<ActionIcon aria-label='delete' onClick={() => openDeleteModal(user)}>
|
||||
<DeleteIcon />
|
||||
</ActionIcon>
|
||||
|
||||
</Group>
|
||||
</Group>
|
||||
</Card>
|
||||
|
|
|
@ -27,6 +27,7 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
const newTarget = await prisma.user.delete({
|
||||
where: { id: target.id },
|
||||
});
|
||||
if (newTarget.administrator) return res.error('cannot delete administrator');
|
||||
|
||||
delete newTarget.password;
|
||||
|
||||
|
|
Loading…
Reference in a new issue