Advertisement
Guest User

Untitled

a guest
Feb 7th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. function changePassword(email, newPassword, callback) {
  2. var mongo = require('mongojs@0.18.2');
  3.  
  4. var db = mongo('mongodb://user:pass@mymongoserver.com/my-db');
  5. var users = db.collection('users');
  6.  
  7. bcrypt.hash(newPassword, 10, function (err, hash) {
  8. if (err) {
  9. callback(err);
  10. } else {
  11. users.update({ email: email }, { $set: { password: hash } }, function (err, count) {
  12. if (err) return callback(err);
  13. callback(null, count > 0);
  14. });
  15. }
  16. });
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement