diff --git a/src/endpoints/admin/admin.ts b/src/endpoints/admin/admin.ts index d499a1e..1bd07e9 100644 --- a/src/endpoints/admin/admin.ts +++ b/src/endpoints/admin/admin.ts @@ -288,6 +288,22 @@ router.post( const { roomId } = req.params; const { idc } = req.body as { idc: string }; try { + const admins = await prisma.rooms.findFirst({ + where: { + roomId: roomId + }, + select: { + adminIdentities: true + } + }) as { adminIdentities: string[] }; + if (!admins) { + res.status(400).json({ error: 'Room not found' }); + return; + } + if (admins.adminIdentities.includes(idc)) { + res.status(400).json({ error: 'Admin already in room' }); + return; + } await prisma.rooms.update({ where: { roomId: roomId diff --git a/src/endpoints/rooms/rooms.ts b/src/endpoints/rooms/rooms.ts index 2880911..e8c5af7 100644 --- a/src/endpoints/rooms/rooms.ts +++ b/src/endpoints/rooms/rooms.ts @@ -338,7 +338,7 @@ router.post('/setpassword/:id', limiter, asyncHandler(async (req: Request, res: res.status(500).send('Error finding room'); }) } else { - res.status(401).json({ success: false, message: 'Unauthorized ' }); + res.status(401).json({ success: false, message: 'Unauthorized' }); } }))