add change password for legged in users
This commit is contained in:
10
index.js
10
index.js
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user