Skip to content
Snippets Groups Projects
Commit 452a9847 authored by Ewen Le Bihan's avatar Ewen Le Bihan
Browse files

fix(login): catch all errors during ldap sync process

parent 5a5ac5df
Branches
Tags v0.16.5
No related merge requests found
......@@ -162,6 +162,7 @@ builder.mutationField('login', (t) =>
// If the user has credentials, consider writing them to our LDAP
if (user.credentials.length >= 0) {
// Check if they are not already in our LDAP
try {
const ldapUser = await queryLdapUser(user.uid);
await log(
'login/ldap-sync',
......@@ -170,6 +171,7 @@ builder.mutationField('login', (t) =>
user.uid
);
if (!ldapUser) {
try {
// Try to find them in the school's LDAP
const schoolUser = await getSupannAliasLogin(user.email);
// eslint-disable-next-line max-depth, no-negated-condition
......@@ -184,8 +186,13 @@ builder.mutationField('login', (t) =>
// Create the LDAP entry
await log('login/ldap-sync', 'start', { user }, user.uid);
const schoolEmail = `${schoolUser.supannAliasLogin}@etu.inp-n7.fr`;
try {
await createLdapUser(
{ ...user, email: schoolEmail, otherEmails: [user.email, ...user.otherEmails] },
{
...user,
email: schoolEmail,
otherEmails: [user.email, ...user.otherEmails],
},
password
);
// Update the users's school uid
......@@ -195,7 +202,16 @@ builder.mutationField('login', (t) =>
schoolUid: schoolUser.schoolUid,
},
});
} catch (error) {
await log('login/ldap-sync', 'error', { err: error }, user.uid);
}
}
} catch (error) {
await log('login/ldap-sync', 'error', { err: error }, user.uid);
}
}
} catch (error) {
await log('login/ldap-sync', 'error', { err: error }, user.uid);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment