Skip to content

Commit af20c3a

Browse files
committed
fix(app): replaced bcrypt with crpyto for windows users
fixes #55
1 parent 13ea60e commit af20c3a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Diff for: templates/common/_package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"mongoose-unique-validator": "~0.3.0",
99
"connect-mongo": "~0.4.0",
1010
"passport": "latest",
11-
"passport-local": "latest",
12-
"bcrypt": "~0.7.7"<% } %><% if (jade) { %>,
11+
"passport-local": "latest"<% } %><% if (jade) { %>,
1312
"jade": "latest"<% } %><% if (!jade) { %>,
1413
"ejs": "~0.8.4"<% } %>
1514
},

Diff for: templates/express/models/user.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var mongoose = require('mongoose'),
44
uniqueValidator = require('mongoose-unique-validator'),
55
Schema = mongoose.Schema,
6-
bcrypt = require('bcrypt');
6+
crypto = require('crypto');
77

88
var authTypes = ['github', 'twitter', 'facebook', 'google'],
99
SALT_WORK_FACTOR = 10;
@@ -130,7 +130,7 @@ UserSchema.methods = {
130130
* @api public
131131
*/
132132
makeSalt: function() {
133-
return bcrypt.genSaltSync(SALT_WORK_FACTOR);
133+
return crypto.randomBytes(16).toString('base64');
134134
},
135135

136136
/**
@@ -141,8 +141,9 @@ UserSchema.methods = {
141141
* @api public
142142
*/
143143
encryptPassword: function(password, salt) {
144-
// hash the password using our new salt
145-
return bcrypt.hashSync(password, salt);
144+
if (!password || !this.salt) return '';
145+
var salt = new Buffer(this.salt, 'base64');
146+
return crypto.pbkdf2Sync(password, salt, 10000, 64).toString('base64');
146147
}
147148
};
148149

0 commit comments

Comments
 (0)