Fix Prettier (#7066)

This commit is contained in:
Diamond Lewis
2020-12-13 11:19:04 -06:00
committed by GitHub
parent d4948572a8
commit 033a0bd443
64 changed files with 697 additions and 1887 deletions

View File

@@ -4,16 +4,12 @@ const Parse = require('parse/node').Parse;
function validateAuthData(authData, options) {
if (!optionsAreValid(options)) {
return new Promise((_, reject) => {
reject(
new Parse.Error(
Parse.Error.INTERNAL_SERVER_ERROR,
'LDAP auth configuration missing'
)
);
reject(new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'LDAP auth configuration missing'));
});
}
const clientOptions = (options.url.startsWith("ldaps://")) ?
{ url: options.url, tlsOptions: options.tlsOptions } : { url: options.url };
const clientOptions = options.url.startsWith('ldaps://')
? { url: options.url, tlsOptions: options.tlsOptions }
: { url: options.url };
const client = ldapjs.createClient(clientOptions);
const userCn =
@@ -23,28 +19,31 @@ function validateAuthData(authData, options) {
return new Promise((resolve, reject) => {
client.bind(userCn, authData.password, ldapError => {
delete(authData.password);
delete authData.password;
if (ldapError) {
let error;
switch (ldapError.code) {
case 49:
error = new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'LDAP: Wrong username or password');
error = new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'LDAP: Wrong username or password'
);
break;
case "DEPTH_ZERO_SELF_SIGNED_CERT":
case 'DEPTH_ZERO_SELF_SIGNED_CERT':
error = new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'LDAPS: Certificate mismatch');
break;
default:
error = new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'LDAP: Somthing went wrong (' + ldapError.code + ')');
error = new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'LDAP: Somthing went wrong (' + ldapError.code + ')'
);
}
reject(error);
client.destroy(ldapError);
return;
}
if (
typeof options.groupCn === 'string' &&
typeof options.groupFilter === 'string'
) {
if (typeof options.groupCn === 'string' && typeof options.groupFilter === 'string') {
searchForGroup(client, options, authData.id, resolve, reject);
} else {
client.unbind();
@@ -61,7 +60,7 @@ function optionsAreValid(options) {
typeof options.suffix === 'string' &&
typeof options.url === 'string' &&
(options.url.startsWith('ldap://') ||
options.url.startsWith('ldaps://') && typeof options.tlsOptions === 'object')
(options.url.startsWith('ldaps://') && typeof options.tlsOptions === 'object'))
);
}
@@ -76,12 +75,7 @@ function searchForGroup(client, options, id, resolve, reject) {
if (searchError) {
client.unbind();
client.destroy();
return reject(
new Parse.Error(
Parse.Error.INTERNAL_SERVER_ERROR,
'LDAP group search failed'
)
);
return reject(new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'LDAP group search failed'));
}
res.on('searchEntry', entry => {
if (entry.object.cn === options.groupCn) {
@@ -96,20 +90,12 @@ function searchForGroup(client, options, id, resolve, reject) {
client.unbind();
client.destroy();
return reject(
new Parse.Error(
Parse.Error.INTERNAL_SERVER_ERROR,
'LDAP: User not in group'
)
new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'LDAP: User not in group')
);
}
});
res.on('error', () => {
return reject(
new Parse.Error(
Parse.Error.INTERNAL_SERVER_ERROR,
'LDAP group search failed'
)
);
return reject(new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'LDAP group search failed'));
});
});
}