Guest User

Untitled

a guest
Jul 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. if (user.validPassword(req.body.password)) {
  2. console.log("two");
  3. }
  4. else {
  5. console.log("three");
  6. }
  7.  
  8. And here is user.js code
  9.  
  10.  
  11. UserSchema.methods.validPassword = function(pass) {
  12. this.salt = crypto.randomBytes(16).toString('hex');
  13. var hash = crypto.pbkdf2Sync(pass, this.salt, 1000, 64, `sha512`).toString(`hex`);
  14. console.log(hash);
  15. return this.hash === hash;
  16. };
Add Comment
Please, Sign In to add comment