From 54f8f67ed5d56bfbd3c5f15c124545279715f96b Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Aug 2021 10:03:40 -0400 Subject: [PATCH] Don't allow username change for banned users --- src/routes/setUsername.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/routes/setUsername.ts b/src/routes/setUsername.ts index 9361216..ec46ea7 100644 --- a/src/routes/setUsername.ts +++ b/src/routes/setUsername.ts @@ -46,8 +46,13 @@ export async function setUsername(req: Request, res: Response): Promise 0) { + const row = await db.prepare("get", `SELECT count(*) as userCount FROM "userNames" WHERE "userID" = ? AND "locked" = '1'`, [userID]); + if (adminUserIDInput === undefined && row.userCount > 0) { + return res.sendStatus(200); + } + + const shadowBanRow = await db.prepare("get", `SELECT count(*) as "userCount" FROM "shadowBannedUsers" WHERE "userID" = ? LIMIT 1`, [userID]); + if (adminUserIDInput === undefined && shadowBanRow.userCount > 0) { return res.sendStatus(200); } }