Added password changing
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user