-
-
Save deedubs/1641857 to your computer and use it in GitHub Desktop.
Revisions
-
Dan Williams revised this gist
Jan 19, 2012 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ var userSchema = new Schema({ email: String , passwordHash: String @@ -8,6 +7,9 @@ userSchema.pre('validate', function(next) { if (this.password === this.passwordConfirm) { this.set('passwordHash', hash(this.password); this.set('passwordHash',undefined); this.set('passwordConfirm',undefined); // How do I prevent this.password and this.passwordConfirm // to be save into DB? } -
shiawuen revised this gist
Jan 19, 2012 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,8 @@ userSchema.pre('validate', function(next) { // How do I prevent this.password and this.passwordConfirm // to be save into DB? } next() }); var User = db.model('User', userSchema); -
shiawuen revised this gist
Jan 19, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,5 +26,5 @@ user.save(function(err) { console.log(!!err ? 'error' : 'saved'); }); function hash(str) { return str+'hashed' } -
shiawuen created this gist
Jan 19, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ var userSchema = new Schema({ email: String , passwordHash: String }); userSchema.pre('validate', function(next) { if (this.password === this.passwordConfirm) { this.set('passwordHash', hash(this.password); // How do I prevent this.password and this.passwordConfirm // to be save into DB? } }); var User = db.model('User', userSchema); var user = new User() user.init({ email: '[email protected]' , password: 'password' , confirmPassword: 'password' }); user.save(function(err) { console.log(!!err ? 'error' : 'saved'); }); function hash(str) { return str+'hashed }