removed required:true from firstname and lastname

This commit is contained in:
Sahat Yalkabov
2013-11-19 13:13:41 -05:00
parent f6aa7740c1
commit 0fcc9492be
2 changed files with 13 additions and 5 deletions

View File

@ -3,10 +3,10 @@ var mongoose = require('mongoose'),
var userSchema = new mongoose.Schema({
email: { type: String, unique: true },
firstName: { type: String, required: true},
lastName: { type: String, required: true},
password: String,
admin: { type: Boolean, default: false },
firstName: String,
lastName: String,
password: String,
provider: String,
facebook: String,
google: String
@ -22,6 +22,16 @@ userSchema.path('email').validate(function(email) {
return email.length;
}, 'Email 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;
var SALT_FACTOR = 5;

View File

@ -1,8 +1,6 @@
extends layout
block content
.main
h3
| Please Login, or