Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. Guest.beforeCreate(function(guest) {
  2. bcrypt.genSalt(10, function(error, salt) {
  3. if (error) { return error }
  4. bcrypt.hash(guest.password, salt, null, function(error, hash) {
  5. if (error) { return error }
  6. guest.password = hash;
  7. })
  8. })
  9. });
  10.  
  11. Guest.beforeCreate(function(guest) {
  12. guest.password = "something";
  13. });
  14.  
  15. Guest.beforeCreate(function(guest) {
  16. bcrypt.genSalt(10, function(error, salt) {
  17. if (error) { return error }
  18. bcrypt.hash(guest.password, salt, null, function(error, hash) {
  19. if (error) { return error }
  20. guest.password = hash;
  21. guest.save(); // Added this line to get it to save.
  22. })
  23. })
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement