Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function validateUser(req, res) {
- var user = req.user;
- var currentPassword = req.body.currentPassword;
- var newPassword = req.body.newPassword;
- var newPasswordConfirmation = req.body.newPasswordConfirmation;
- bcrypt.hash(currentPassword, ENCRYPTION_PASSES, (err, hash) => {
- if(err) return failure(req, res);
- console.log("Provided Password: " + currentPassword);
- db.get("SELECT cryptedPassword FROM users WHERE username = ?", user.username, (err, row) => {
- if(err) failure(req, res, error);
- if(row.cryptedPassword != hash) failure(req, res, "Incorrect password");
- if(typeof newPassword !== "string" || newPassword.length < 10)
- return failure(req, res, "Password must be at least ten characters in length");
- if(newPassword !== newPasswordConfirmation)
- return failure(req, res, "New Password and New Password Confirmation must match");
- user.password = newPassword;
- console.log("New Password: " + user.password);
- createPasswordHash(req, res, user);
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement