Skip to content

Can't set the same email to two users #27626

Closed

Description

@PVince81

Steps:

  1. Create two users "user1" and "user2"
  2. Set the same email address to both users as admin

Expected result

Possibly to set to two users

Actual result

Setting it to the second user as admin shows a spinner and never stops.
Also: if setting it through the user's personal page, when opening the link to validate the email address there will be an "Internal Server Error" page.

Additional potential issues (to be tested)

  • if LDAP has two users where both have the same email address (ex: an admin who has two accounts, one as admin, one as regular user but still wishes to receive email to the same address), it is likely to break on sync.
  • if a previous setup already had users with the same email address, migrating to 10.0 will likely break somewhere. (I couldn't test with local users due to this other bug Email address not imported to oc_accounts from oc_preferences on upgrade #27625)

I suggest making the email column non-unique.
@DeepDiver1975 @butonic @jvillafanez

cc @pmaier1

Activity

  1. added this to the 10.0 milestone on Apr 11, 2017
  2. pmaier1 commented on Apr 11, 2017

    @pmaier1
    Contributor

    Just discovered this myself when using the guest app and trying to add a user with an address that I specified for another user before. Anyway for the guest app it should share with the user that specified the respective address instead of creating a new user. Will provide this as feedback for guests separately.

  3. PVince81 commented on Apr 12, 2017

    @PVince81
    ContributorAuthor

    @DeepDiver1975 now that #27635 is merged it is possible to break the update this way:

    1. Setup stable9.1
    2. Create two users with the same email address
    3. Upgrade to master
    ± % ./occ upgrade
    ownCloud or one of the apps require upgrade - only a limited number of commands are available
    You may use your browser or the occ upgrade command to do the upgrade
    Set log level to debug
    Turned on maintenance mode
    Updating database schema
    Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing 'INSERT INTO `oc_accounts`(`lower_user_id`,`user_id`,`state`,`backend`,`home`,`display_name`,`email`) VALUES(?,?,?,?,?,?,?)' with params ["user2", "user2", 1, "OC\\User\\Database", "\/srv\/www\/htdocs\/owncloud\/data\/user2", "user2", "vincent@petry"]:
    
    SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'vincent@petry' for key 'UNIQ_907AA303E7927C74'
    Update failed
    Maintenance mode is kept active
    Reset log level
    
  4. felixboehm commented on Apr 13, 2017

    @felixboehm
    Contributor

    you can login with the email field, so I would expect that we prevent adding an email that is already used. What is the solution in mind?
    @pmaier1 @hodyroff

  5. PVince81 commented on Apr 13, 2017

    @PVince81
    ContributorAuthor

    you can login with the email field

    This only works if a single user has an email address set.

    If two users have the same email address then the login is denied. This was the logic in 9.1.

    If we do want to keep blocking duplicate emails, then we need to think about how to migrate setups that had duplicate emails in the past.

    And here I'm only talking about DB users.

    LDAP might also have entries where multiple users have the same email address, but login with email feature only applies to DB users. For LDAP users, the admin can configure the login fields in the LDAP wizard. Now I don't know what happens with LDAP if two users has the same email address and email is set as login field... @jvillafanez @davitol can you try this out ?

  6. PVince81 commented on Apr 18, 2017

    @PVince81
    ContributorAuthor

    Talked with @DeepDiver1975 and this is the way we'll go:

    • duplicate email addresses are forbidden (previous versions did allow that)
    • when upgrading, only pick the first email address found (first found user, not necessarily alphabetical). second user who has the email address will get an empty field, no failure
    • when importing users from LDAP or other user backends (occ user:sync), write an empty email address in case it is duplicate with another one
    • log a warning when a duplicate was found for admins to track the problem
  7. PVince81 commented on Apr 18, 2017

    @PVince81
    ContributorAuthor

    This also means that if a user tries to manually set an email address to an existing one, we'll show a warning "email address already in use in the system, please use another one". This could make it possible for a user to guess what users has an account on the system. Probably not a real security risk, @Peter-Prochaska please confirm.

    If we consider this a potential risk, then we need to not show an error message but keep the regular "an email has been sent for confirmation" but not actually send anything ?

  8. PVince81 commented on Apr 18, 2017

    @PVince81
    ContributorAuthor

    And if an admin manually sets a duplicate email address there will directly get an error in the UI.

    • set email address method must throw exception in case of duplicate
    • catch exception and set email to empty again, log a warning
    • when setting duplicate email as regular user, lie and say an email was sent when none was sent (see Can't set the same email to two users #27626 (comment)), and log a warning message for the admin
    • when setting duplicate email as admin, show error message
  9. PVince81 commented on Apr 18, 2017

    @PVince81
    ContributorAuthor
    • provisioning API must return an error code in case of duplicates, don't set an empty email
  10. 50 remaining items

  11. pmaier1 commented on Feb 5, 2018

    @pmaier1
    Contributor

    At least endless spinner and internal server error issues (mentioned in OP) need to be fixed. For many users the mail address is the only unique identifier for e.g. receiving shares or for preventing duplicate accounts. Therefore I don't think we are going to change the basic design on this unless there are other important arguments.

  12. reopened this on Feb 5, 2018
  13. jvillafanez commented on Feb 8, 2018

    @jvillafanez
    Member

    It should be possible to set the uid / login to an email-like string. This should provide something similar to a login by email although it's in fact a regular login. Note that in this case, that uid won't be changeable.

    Another more complex approach could be that, from a list of emails that a user could have, mark one of those as "possible to log in with". In this case, we have to verify if such email is unique before allowing it. Then we can use that email to login with that user.

    During user sync, any (valid?) email can be added into the DB, but none of them will be set as "possible to log in with".
    While this should solve the problems regarding login with email, there could be other problems with the email usage. If I want to send an email, what email address should I use? what if several users have the same email?

    In any case, I don't think this will be an easy change to do, so we have to check if this is worthy, and the scenarios and setups where this can be useful.

  14. stale commented on Sep 21, 2021

    @stale

    This issue has been automatically closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions