Made salt key not required

Mongoose's validation kept blocking the operation.
We need this to go through to the pre-save hook
This commit is contained in:
Adrian Obelmejias
2016-02-11 19:01:15 -05:00
parent 8b4cdd5886
commit 2e40b09bba
+2 -1
View File
@@ -6,7 +6,7 @@ const User = new mongoose.Schema({
name: { type: String },
username: { type: String, required: true, unique: true },
password: { type: String, required: true },
salt: { type: String, required: true }
salt: { type: String }
})
User.pre('save', function(next) {
@@ -23,6 +23,7 @@ User.pre('save', function(next) {
if(err) { return next(err) }
user.password = hash
user.salt = salt
next()
})
})