Permalink
Browse files

only create salt if it doesn't exist

  • Loading branch information...
1 parent 0dd510e commit 526bf31c5949a8ad039ec23c2fa8944224722d23 Jason Brant committed Dec 31, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/mongoose-hashed-password.js
@@ -21,7 +21,9 @@ Schema.prototype.defineHashedPassword = function (algorithm, validate) {
this.virtual('password').set(function (pw) {
this._password = pw;
- this.salt = this.createSalt();
+ if (!this.salt) {
+ this.salt = this.createSalt();
+ }
this.hashed_password = this.encryptPassword(pw);
}).get(function () {
return this._password;

0 comments on commit 526bf31

Please sign in to comment.