diff options
Diffstat (limited to 'api/src/routes/users/@me/delete.ts')
-rw-r--r-- | api/src/routes/users/@me/delete.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/api/src/routes/users/@me/delete.ts b/api/src/routes/users/@me/delete.ts index fa8134cc..6bfe0b93 100644 --- a/api/src/routes/users/@me/delete.ts +++ b/api/src/routes/users/@me/delete.ts @@ -5,12 +5,19 @@ const router = Router(); router.post("/", async (req: Request, res: Response) => { const user = await User.findOneOrFail({ id: 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 :/ + } + + // TODO: decrement guild member count - let correctpass = await bcrypt.compare(req.body.password, user!.data.hash); //Not sure if user typed right password :/ if (correctpass) { await Promise.all([ - User.deleteOne({ id: req.user_id }), //Yeetus user deletus - Member.deleteMany({ id: req.user_id }) + User.delete({ id: req.user_id }), //Yeetus user deletus + Member.delete({ id: req.user_id }) ]); res.sendStatus(204); |