Created
April 6, 2016 15:42
-
-
Save edesilets/7f34a886e0a3af47435eaf8061aaedcd to your computer and use it in GitHub Desktop.
Abridged express/app/controllers/users.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const changepw = (req, res, next) => { | |
debug('Changing password'); | |
let credentials = req.body.passwords; | |
let search = { | |
id: req.params.id, | |
token: req.currentUser.token, | |
}; | |
new User(search).fetch() | |
.then((data) => { | |
if (data) { | |
data.comparePassword(req.body.passwords.old).then((fucker) => { | |
delete fucker.passwordDigest; | |
console.log('fucker: \n',fucker); | |
new User(fucker).setPassword(credentials.new).save();//.then((thing)=> {console.log('this shit.....'); res.sendStatus(200)}); //thing, { patch: true }.save(this, {patch: true}) | |
}); | |
} else { | |
Promise.reject(new HttpError(404)); | |
} | |
}) | |
.then(console.log); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment