add change password for legged in users

This commit is contained in:
aeroreyna
2022-09-07 22:54:52 -04:00
parent 139f4ab086
commit 605ddac037

View File

@@ -178,7 +178,15 @@ DB.getDB.then((DB) => {
const user_sid = getUserId(req); const user_sid = getUserId(req);
if (session_id && user_sid) { if (session_id && user_sid) {
const userInfo = await DB.checkSessionOnDB(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 username = req.body.username;
const user = await DB.getUser(username); const user = await DB.getUser(username);