Commit 1778948e authored by simon's avatar simon

chore: bring everything up2date

parent 4711c385
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -79,7 +79,7 @@ export class GoogleLDAPAuth implements IAuthentication {
return;
}
res.on('searchEntry', function (entry) {
res.on('searchEntry', (entry) => {
// log('entry: ' + JSON.stringify(entry.object));
usernameFields.forEach((field) => {
const index = entry.object[field] as string;
......@@ -87,11 +87,11 @@ export class GoogleLDAPAuth implements IAuthentication {
});
});
res.on('searchReference', function (referral) {
res.on('searchReference', (referral) => {
log(`referral: ${referral.uris.join()}`);
});
res.on('error', function (ldapErr) {
res.on('error', (ldapErr) => {
console.error(`error: ${JSON.stringify(ldapErr)}`);
reject(ldapErr);
});
......@@ -110,7 +110,12 @@ export class GoogleLDAPAuth implements IAuthentication {
this.lastDNsFetch = new Date();
}
async authenticate(username: string, password: string, count = 0, forceFetching = false) {
async authenticate(
username: string,
password: string,
count = 0,
forceFetching = false
): Promise<boolean> {
const cacheValidTime = new Date();
cacheValidTime.setHours(cacheValidTime.getHours() - 12);
......@@ -150,7 +155,7 @@ export class GoogleLDAPAuth implements IAuthentication {
authClient.bind(dn, password, (err, res) => {
if (err) {
if (err && (err as any).stack && (err as any).stack.includes(`ldap.google.com closed`)) {
count++;
count += 1;
// wait 1 second to give the ldap error handler time to reconnect
setTimeout(() => resolve(this.authenticate(dn, password)), 2000);
return;
......@@ -167,6 +172,6 @@ export class GoogleLDAPAuth implements IAuthentication {
});
});
return !!authResult;
return authResult;
}
}
......@@ -43,14 +43,14 @@ export class LDAPAuth implements IAuthentication {
searchFilter: config.searchFilter || '(uid={{username}})',
reconnect: true,
});
this.ldap.on('error', function (err) {
this.ldap.on('error', (err) => {
console.error('LdapAuth: ', err);
});
}
async authenticate(username: string, password: string) {
async authenticate(username: string, password: string): Promise<boolean> {
const authResult: boolean = await new Promise((resolve, reject) => {
this.ldap.authenticate(username, password, function (err, user) {
this.ldap.authenticate(username, password, (err, user) => {
if (err) {
resolve(false);
console.error('ldap error', err);
......@@ -61,6 +61,6 @@ export class LDAPAuth implements IAuthentication {
});
});
return !!authResult;
return authResult;
}
}
......@@ -86,9 +86,9 @@ export class EAPPacketHandler implements IPacketHandler {
supportedEAPMethods.push(supportedMethod);
}
currentState.validMethods = currentState.validMethods.filter((method) => {
return supportedEAPMethods.includes(method.getEAPType()); // kick it out?
});
currentState.validMethods = currentState.validMethods.filter(
(method) => supportedEAPMethods.includes(method.getEAPType()) // kick it out?
);
// save
this.eapConnectionStates.set(stateID, currentState);
......@@ -101,9 +101,7 @@ export class EAPPacketHandler implements IPacketHandler {
// continue with responding a NAK and add rest of supported methods
// eslint-disable-next-line no-fallthrough
default: {
const eapMethod = this.eapMethods.find((method) => {
return type === method.getEAPType();
});
const eapMethod = this.eapMethods.find((method) => type === method.getEAPType());
if (eapMethod) {
return eapMethod.handleMessage(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment