diff --git a/index.js b/index.js index f8a33d2..66f3fb7 100644 --- a/index.js +++ b/index.js @@ -178,7 +178,15 @@ DB.getDB.then((DB) => { const user_sid = getUserId(req); if (session_id && user_sid) { const userInfo = await DB.checkSessionOnDB(session_id, user_sid); - if (userInfo) return res.redirect('/'); + if (userInfo){ + const password = req.body.password; + const hashedPassword = await bcrypt.hash(password, 10); + DB.resetUserPassword(userInfo.username, hashedPassword); + return res.json({ + status: "ok", + details: 'password changed!' + }); + } } const username = req.body.username; const user = await DB.getUser(username);