fix: use correct super_admin role in group ownership transfer check
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -417,7 +417,7 @@ const chatRoutes: FastifyPluginAsync = async (fastify) => {
|
|||||||
// Transfer ownership (only current owner or admin can do this)
|
// Transfer ownership (only current owner or admin can do this)
|
||||||
if (transferOwnerTo) {
|
if (transferOwnerTo) {
|
||||||
const userId = request.user.sub
|
const userId = request.user.sub
|
||||||
if (createdBy !== userId && request.user.role !== 'admin') {
|
if (createdBy !== userId && request.user.role !== 'super_admin') {
|
||||||
return reply.code(403).send({ error: 'Only the group creator can transfer ownership' })
|
return reply.code(403).send({ error: 'Only the group creator can transfer ownership' })
|
||||||
}
|
}
|
||||||
await db.query('UPDATE chat_rooms SET created_by = $1 WHERE id = $2', [transferOwnerTo, roomId])
|
await db.query('UPDATE chat_rooms SET created_by = $1 WHERE id = $2', [transferOwnerTo, roomId])
|
||||||
|
|||||||
Reference in New Issue
Block a user