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