Only create external ldap users for oauth logins
This commit is contained in:
17
src/users.js
17
src/users.js
@@ -32,7 +32,6 @@ exports = module.exports = {
|
||||
};
|
||||
|
||||
let assert = require('assert'),
|
||||
auditSource = require('./auditsource.js'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
crypto = require('crypto'),
|
||||
constants = require('./constants.js'),
|
||||
@@ -241,27 +240,12 @@ function verify(userId, password, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function createAndVerifyUserIfNotExist(identifier, password, callback) {
|
||||
assert.strictEqual(typeof identifier, 'string');
|
||||
assert.strictEqual(typeof password, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
externalLdap.createAndVerifyUserIfNotExist(identifier, password, function (error, result) {
|
||||
if (error && error.reason === BoxError.BAD_STATE) return callback(new BoxError(BoxError.NOT_FOUND));
|
||||
if (error && error.reason === BoxError.BAD_FIELD) return callback(new BoxError(BoxError.NOT_FOUND));
|
||||
if (error) return callback(error);
|
||||
|
||||
callback(null, result);
|
||||
});
|
||||
}
|
||||
|
||||
function verifyWithUsername(username, password, callback) {
|
||||
assert.strictEqual(typeof username, 'string');
|
||||
assert.strictEqual(typeof password, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
userdb.getByUsername(username.toLowerCase(), function (error, user) {
|
||||
if (error && error.reason === BoxError.NOT_FOUND) return createAndVerifyUserIfNotExist(username.toLowerCase(), password, callback);
|
||||
if (error) return callback(error);
|
||||
|
||||
verify(user.id, password, callback);
|
||||
@@ -274,7 +258,6 @@ function verifyWithEmail(email, password, callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
userdb.getByEmail(email.toLowerCase(), function (error, user) {
|
||||
if (error && error.reason === BoxError.NOT_FOUND) return createAndVerifyUserIfNotExist(email.toLowerCase(), password, callback);
|
||||
if (error) return callback(error);
|
||||
|
||||
verify(user.id, password, callback);
|
||||
|
||||
Reference in New Issue
Block a user