Skip to content

Commit

Permalink
fix(app): replaced bcrypt with crpyto for windows users
Browse files Browse the repository at this point in the history
fixes #55
  • Loading branch information
DaftMonk committed Jan 16, 2014
1 parent 13ea60e commit af20c3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions templates/common/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"mongoose-unique-validator": "~0.3.0",
"connect-mongo": "~0.4.0",
"passport": "latest",
"passport-local": "latest",
"bcrypt": "~0.7.7"<% } %><% if (jade) { %>,
"passport-local": "latest"<% } %><% if (jade) { %>,
"jade": "latest"<% } %><% if (!jade) { %>,
"ejs": "~0.8.4"<% } %>
},
Expand Down
9 changes: 5 additions & 4 deletions templates/express/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var mongoose = require('mongoose'),
uniqueValidator = require('mongoose-unique-validator'),
Schema = mongoose.Schema,
bcrypt = require('bcrypt');
crypto = require('crypto');

var authTypes = ['github', 'twitter', 'facebook', 'google'],
SALT_WORK_FACTOR = 10;
Expand Down Expand Up @@ -130,7 +130,7 @@ UserSchema.methods = {
* @api public
*/
makeSalt: function() {
return bcrypt.genSaltSync(SALT_WORK_FACTOR);
return crypto.randomBytes(16).toString('base64');
},

/**
Expand All @@ -141,8 +141,9 @@ UserSchema.methods = {
* @api public
*/
encryptPassword: function(password, salt) {
// hash the password using our new salt
return bcrypt.hashSync(password, salt);
if (!password || !this.salt) return '';
var salt = new Buffer(this.salt, 'base64');
return crypto.pbkdf2Sync(password, salt, 10000, 64).toString('base64');
}
};

Expand Down

0 comments on commit af20c3a

Please sign in to comment.