summary refs log tree commit diff
path: root/api/src/routes/users/@me/disable.ts
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/routes/users/@me/disable.ts')
-rw-r--r--api/src/routes/users/@me/disable.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/api/src/routes/users/@me/disable.ts b/api/src/routes/users/@me/disable.ts
index a40c9e59..ed1dedcc 100644
--- a/api/src/routes/users/@me/disable.ts
+++ b/api/src/routes/users/@me/disable.ts
@@ -5,9 +5,14 @@ import bcrypt from "bcrypt";
 const router = Router();
 
 router.post("/", async (req: Request, res: Response) => {
-	const user = await User.findOneOrFail({ id: req.user_id }); //User object
+	const user = await User.findOneOrFail(req.user_id); //User object
+	let correctpass = true;
+
+	if (user.data.hash) {
+		// guest accounts can delete accounts without password
+		correctpass = await bcrypt.compare(req.body.password, user.data.hash); //Not sure if user typed right password :/
+	}
 
-	let correctpass = await bcrypt.compare(req.body.password, user!.data.hash); //Not sure if user typed right password :/
 	if (correctpass) {
 		await User.update({ id: req.user_id }, { disabled: true });