Guest User

Untitled

a guest
Aug 25th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. var User = Waterline.Collection.extend({
  2.  
  3. identity: 'user',
  4. connection: 'local-postgresql',
  5.  
  6. attributes: {
  7.  
  8. username: {
  9. type: 'string',
  10. required: true
  11. },
  12.  
  13. password: {
  14. type: 'string',
  15. minLength: 6,
  16. required: true,
  17. columnName: 'encrypted_password'
  18. }
  19.  
  20. },
  21.  
  22. // Lifecycle Callbacks
  23. beforeCreate: function(values, next) {
  24. (async () => {
  25. try{
  26. values.password = await bcrypt.hash(values.password, 10);
  27. return next(values);
  28. }catch(e){
  29. return next(error);
  30. }
  31. })();
  32. }
  33. });
Advertisement
Add Comment
Please, Sign In to add comment