Skip to content

Commit

Permalink
BE #1 add password validation during signup
Browse files Browse the repository at this point in the history
  • Loading branch information
tito433 committed May 8, 2020
1 parent 2e984fb commit 44b5b9c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ var User = new Schema({
}
});

User.plugin(passportLocalMongoose);
User.plugin(passportLocalMongoose,{
usernameLowerCase:true,
passwordValidator : (password,cb)=>{
if (!password.trim()) {
return cb('Password can not be empty!');
}else if(password.trim().length<8){
return cb('Password must be at least 8 chars long');
}
// return an empty cb() on success
return cb()
}
});

module.exports = mongoose.model('User', User);

0 comments on commit 44b5b9c

Please sign in to comment.