Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var User = Waterline.Collection.extend({
- identity: 'user',
- connection: 'local-postgresql',
- attributes: {
- username: {
- type: 'string',
- required: true
- },
- password: {
- type: 'string',
- minLength: 6,
- required: true,
- columnName: 'encrypted_password'
- }
- },
- // Lifecycle Callbacks
- beforeCreate: function(values, next) {
- (async () => {
- try{
- values.password = await bcrypt.hash(values.password, 10);
- return next(values);
- }catch(e){
- return next(error);
- }
- })();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment