Simplified local strategy signup process, email is now a username

This commit is contained in:
Sahat Yalkabov
2013-12-05 22:48:09 -05:00
parent 0c842286ef
commit 3ecd3ad148
3 changed files with 15 additions and 37 deletions

View File

@ -16,7 +16,7 @@ var userSchema = new mongoose.Schema({
provider: String,
facebook: String,
google: String,
isAdmin: Boolean,
isAdmin: Boolean
});
userSchema.path('password').validate(function(password) {
@ -24,20 +24,11 @@ userSchema.path('password').validate(function(password) {
return password.length;
}, 'Password cannot be blank');
userSchema.path('email').validate(function(email) {
userSchema.path('username').validate(function(username) {
if (this.provider) return true;
return email.length;
}, 'Email cannot be blank');
return username.length;
}, 'Username cannot be blank');
userSchema.path('firstName').validate(function(firstName) {
if (this.provider) return true;
return firstName.length;
}, 'First Name cannot be blank');
userSchema.path('lastName').validate(function(lastName) {
if (this.provider) return true;
return lastName.length;
}, 'Last Name cannot be blank');
userSchema.pre('save', function(next) {
var user = this;