mirror of
https://github.com/diced/zipline.git
synced 2025-04-11 23:31:17 -05:00
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…
Add table
Reference in a new issue