Skip to content

Email address might be stored twice in database #11251

Closed
@CirnoT

Description

@CirnoT
  • Gitea version (or commit ref): 1.12.0+dev-231-g1bf9e44bd
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

It is possible to use 'Manage Email Addresses' to add an email that already exists, if the specified email is primary. Specifically, the isEmailUsed in models/user_mail.go only checks for duplicates in email_address table, but we also store the email in user table. This leads to an odd situation, where same email is present twice in database.

The same is possible if MakeEmailPrimary is executed, as it does not remove previous entry from email_address table.

We should most likely remove email from user table and keep separate column for whether email is primary or not, in email_address.

The above results in duplicate entries being presented in User Emails part of Site Administration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/confirmedIssue has been reviewed and confirmed to be present or accepted to be implementedtype/bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions