Allow user accounts to be merged if the username/email already exists

Created on 8 January 2021, over 3 years ago
Updated 4 April 2023, about 1 year ago

Problem/Motivation

simpleSAMLphp auth should be capable of merging with existing Drupal user accounts without crashing when a username/email conflict occurs.

It throws the following:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'my-username' for key 'name': INSERT INTO {users} (uid, name, pass, created, access, status, init, uuid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => 16602 [:db_insert_placeholder_1] => redacted [:db_insert_placeholder_2] => redacted [:db_insert_placeholder_3] => 1610106922 [:db_insert_placeholder_4] => 1610106922 [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => redacted [:db_insert_placeholder_7] => redacted ) in drupal_write_record() (line 7460 of /app/application/web/includes/common.inc).

Steps to reproduce

Example use case:

- User A has an existing Drupal account with username usera and email usera@example.com.
- simpleSAMLphp should be able to detect that user during the login process rather than crashing because the email or username is already in use.

Proposed resolution

Provide configuration options for administrators to decide what to do during the situation. Either merge/abort the login.

And if there's an edge case where two accounts exist (account 1 with the username, and account 2 with the email, then it should abort for the admin to clean up).

Remaining tasks

Provide a patch/PR.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States laryn

    I was running into this issue on a Backdrop site and have tested a slightly modified patch over there (only modified for Backdrop-specific details like config instead of variables, authmap function name change, etc.) and it seems to be working great.

    I've duplicated this issue and filed the derivative PR here:
    https://github.com/backdrop-contrib/simplesamlphp_auth/issues/24

    One minor textual suggestion. @codebymikey on this line:

    > Note that the option to allow the login and external accounts should only be used...

    Should it rather be the following?

    > Note that the option to allow the login and link accounts should only be used...

Production build 0.69.0 2024