Added password changing

This commit is contained in:
2021-02-27 04:38:59 +11:00
parent 2d7f6894ab
commit 648f8a16cc
4 changed files with 35 additions and 8 deletions
+7 -1
View File
@@ -1,3 +1,4 @@
const bcrypt = require('bcryptjs');
const { accounts } = require('../database/models');
const route = async (req, res) => {
@@ -5,9 +6,14 @@ const route = async (req, res) => {
return res.status(500).send('missing account data');
}
//generate the password hash
const salt = await bcrypt.genSalt(11);
const hash = await bcrypt.hash(req.fields.password, salt);
//update the account
await accounts.update({
contact: req.fields.contact
contact: req.fields.contact,
hash: hash
}, {
where: {
id: req.session.account.id