Adds bcrypt native binding for better login performance (#2549)

* Adds bcrypt native binding for better login performance

* Swaps bcrypt-nodejs for bcryptjs as compatible with bcrypt native

* Fixes package versions
This commit is contained in:
Florent Vilmart
2016-08-19 16:53:57 -04:00
committed by Drew
parent 9429659d90
commit 3a08ec9ce8
3 changed files with 24 additions and 5 deletions

View File

@@ -1,11 +1,15 @@
// Tools for encrypting and decrypting passwords.
// Basically promise-friendly wrappers for bcrypt.
var bcrypt = require('bcrypt-nodejs');
var bcrypt = require('bcryptjs');
try {
bcrypt = require('bcrypt');
} catch(e) {}
// Returns a promise for a hashed password string.
function hash(password) {
return new Promise(function(fulfill, reject) {
bcrypt.hash(password, null, null, function(err, hashedPassword) {
bcrypt.hash(password, 10, function(err, hashedPassword) {
if (err) {
reject(err);
} else {