Move ExternalLdapError to BoxError

This commit is contained in:
Girish Ramakrishnan
2019-10-24 13:41:41 -07:00
parent 1a8496d61e
commit d2c12297dc
5 changed files with 30 additions and 62 deletions
+1 -5
View File
@@ -102,7 +102,6 @@ var addons = require('./addons.js'),
debug = require('debug')('box:settings'),
docker = require('./docker.js'),
externalldap = require('./externalldap.js'),
ExternalLdapError = externalldap.ExternalLdapError,
moment = require('moment-timezone'),
paths = require('./paths.js'),
safe = require('safetydance'),
@@ -414,10 +413,7 @@ function setExternalLdapConfig(externalLdapConfig, callback) {
assert.strictEqual(typeof callback, 'function');
externalldap.testConfig(externalLdapConfig, function (error) {
if (error && error.reason === ExternalLdapError.BAD_FIELD) return callback(new BoxError(BoxError.BAD_FIELD, error.message));
if (error && error.reason === ExternalLdapError.EXTERNAL_ERROR) return callback(new BoxError(BoxError.EXTERNAL_ERROR, error.message));
if (error && error.reason === ExternalLdapError.INVALID_CREDENTIALS) return callback(new BoxError(BoxError.BAD_FIELD, 'invalid bind credentials'));
if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error));
if (error) return callback(error);
settingsdb.set(exports.EXTERNAL_LDAP_KEY, JSON.stringify(externalLdapConfig), function (error) {
if (error) return callback(error);