diff --git a/packages/backend/src/server/api/endpoints/admin/admin/remove.ts b/packages/backend/src/server/api/endpoints/admin/admin/remove.ts index 409784f8b161..1db857c9f3ff 100644 --- a/packages/backend/src/server/api/endpoints/admin/admin/remove.ts +++ b/packages/backend/src/server/api/endpoints/admin/admin/remove.ts @@ -18,13 +18,17 @@ export const paramDef = { } as const; // eslint-disable-next-line import/no-default-export -export default define(meta, paramDef, async (ps) => { +export default define(meta, paramDef, async (ps, me) => { const user = await Users.findOneBy({ id: ps.userId }); if (user == null) { throw new Error('user not found'); } + if (user.id === me.id) { + throw new Error('cannot remove yourself'); + } + await Users.update(user.id, { isAdmin: false, });