Skip to content

Instantly share code, notes, and snippets.

@edesilets
Created April 6, 2016 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edesilets/7f34a886e0a3af47435eaf8061aaedcd to your computer and use it in GitHub Desktop.
Save edesilets/7f34a886e0a3af47435eaf8061aaedcd to your computer and use it in GitHub Desktop.
Abridged express/app/controllers/users.js
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