Allow native bcrypt for performance

See https://github.com/strongloop/loopback/issues/892
This commit is contained in:
Raymond Feng 2014-12-03 09:03:36 -08:00
parent 837f61c2b1
commit 1e932e72ed
1 changed files with 10 additions and 1 deletions

View File

@ -6,7 +6,16 @@ var loopback = require('../../lib/loopback');
var path = require('path');
var SALT_WORK_FACTOR = 10;
var crypto = require('crypto');
var bcrypt = require('bcryptjs');
var bcrypt;
try {
// Try the native module first
bcrypt = require('bcrypt');
} catch (err) {
// Fall back to pure JS impl
bcrypt = require('bcryptjs');
}
var DEFAULT_TTL = 1209600; // 2 weeks in seconds
var DEFAULT_RESET_PW_TTL = 15 * 60; // 15 mins in seconds
var DEFAULT_MAX_TTL = 31556926; // 1 year in seconds