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

View File

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