From 2161ec047ba7fc1f345e50ebb25cd31b57ce74d7 Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Sun, 19 Feb 2023 05:12:10 +0900 Subject: [PATCH] =?UTF-8?q?hotfix(server):=20=E8=87=AA=E5=88=86=E8=87=AA?= =?UTF-8?q?=E8=BA=AB=E3=81=AE=E5=A0=B4=E5=90=88=E7=AE=A1=E7=90=86=E8=80=85?= =?UTF-8?q?=E6=A8=A9=E9=99=90=E3=82=92=E5=89=8A=E9=99=A4=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=20#22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/src/server/api/endpoints/admin/admin/remove.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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, });