Skip to content

Commit

Permalink
Linking: account for both accounts being LDAP primary
Browse files Browse the repository at this point in the history
  • Loading branch information
dividehex committed Nov 29, 2023
1 parent 4199547 commit 39b854c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rules/link-users-by-email-with-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@ function linkUsersByEmailWithMetadata(user, context, callback) {
});

const linkAccount = (otherProfile) => {
// sanity check if both accounts have LDAP as primary
// we should NOT link these accounts and simply allow the user to continue logging in.
if (user.user_id.startsWith('ad|Mozilla-LDAP') && otherProfile.user_id.startsWith('ad|Mozilla-LDAP')) {
console.error(`Error: both ${user.user_id} and ${otherProfile.user_id} are LDAP Primary accounts. Linking will not occur.`);
return callback(null, user, context); // Continue with user login without account linking
}
// LDAP takes priority being the primary identity
// So we need to determine if one or neither are LDAP
// If both are non-primary, linking order doesn't matter
var primaryUser = {};
var secondaryUser = {};
if (user.user_id.startsWith('ad|Mozilla-LDAP')) {
Expand Down

0 comments on commit 39b854c

Please sign in to comment.