From a9789697e754723425b5444ed9d6874c10813cd8 Mon Sep 17 00:00:00 2001 From: dceejay Date: Thu, 19 Mar 2015 11:36:48 +0000 Subject: [PATCH] add bcrypt as optional dependency to speed up Pi, but not force compile on Windows. Fix to close Issue #585 --- package.json | 3 +++ red/api/auth/users.js | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 27345d929..fa091a44d 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,9 @@ "passport-oauth2-client-password":"0.1.2", "oauth2orize":"1.0.1" }, + "optionalDependencies": { + "bcrypt":"0.8.1" + }, "devDependencies": { "grunt": "0.4.5", "grunt-cli": "0.1.13", diff --git a/red/api/auth/users.js b/red/api/auth/users.js index 15b05687a..10d9b329b 100644 --- a/red/api/auth/users.js +++ b/red/api/auth/users.js @@ -16,8 +16,9 @@ var when = require("when"); var util = require("util"); -var bcrypt = require('bcryptjs'); - +var bcrypt; +try { bcrypt = require('bcrypt'); } +catch(e) { bcrypt = require('bcryptjs'); } var users = {}; var passwords = {}; var defaultUser = null; @@ -56,6 +57,7 @@ function init(config) { api.get = config.users; } else { var us = config.users; + /* istanbul ignore else */ if (!util.isArray(us)) { us = [us]; } @@ -97,5 +99,3 @@ module.exports = { authenticate: function(username,password) { return api.authenticate(username,password) }, default: function() { return api.default(); } }; - -