Created
July 31, 2014 16:05
-
-
Save artcommacode/ceff41f2fb9ba7321730 to your computer and use it in GitHub Desktop.
This file contains 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 characters
sUser.pre('save', co(function *(next) { | |
if (!this.isModified('password')) return next(); | |
this.password = yield this.encryptPassword(this.password) | |
return next() | |
})) | |
sUser.methods.encryptPassword = function *(password) { | |
var salt = yield thunkify(bcrypt.genSalt)(10) | |
return yield thunkify(bcrypt.hash)(password, salt, null) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment