Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 1x |
/**
* Checks to see if the specified username exists.
*
* @param {Object} [opts] Optional LDAP query string parameters to execute. { scope: '', filter: '', attributes: [ '', '', ... ], sizeLimit: 0, timelimit: 0 }
* @param {String} username The username to check to see if it exits.
* @param {Function} callback The callback to execute when completed. callback(err: {Object}, result: {Boolean})
*/
function userExists(opts, username, callback) {
var self = this;
return new Promise((resolve, reject) => {
if (typeof (username) === 'function') {
callback = username;
username = opts;
opts = undefined;
}
log.trace('userExists(%j,%s)', opts, username);
self.findUser(opts, username, function (err, user) {
if (err) {
if(callback){
callback(err);
}
return reject(err);
}
log.info('"%s" %s exist.', username, (user != null) ? 'DOES' : 'DOES NOT');
if(callback){
callback(null, user != null);
}
return resolve(user != null);
});
});
};
module.exports = userExists; |