From 0fcc9492beb23db6150399408ea57081442728c9 Mon Sep 17 00:00:00 2001 From: Sahat Yalkabov Date: Tue, 19 Nov 2013 13:13:41 -0500 Subject: [PATCH] removed required:true from firstname and lastname --- models/user.js | 16 +++++++++++++--- views/login.jade | 2 -- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/models/user.js b/models/user.js index f9c10331ec..f670f12ed1 100644 --- a/models/user.js +++ b/models/user.js @@ -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; diff --git a/views/login.jade b/views/login.jade index e49fb4e6b9..dcc958cb19 100644 --- a/views/login.jade +++ b/views/login.jade @@ -1,8 +1,6 @@ extends layout block content - - .main h3 | Please Login, or