Email address might be stored twice in database #5326

Closed
opened 2025-11-02 06:21:39 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @CirnoT on GitHub (Apr 29, 2020).

  • 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.

Originally created by @CirnoT on GitHub (Apr 29, 2020). - Gitea version (or commit ref): 1.12.0+dev-231-g1bf9e44bd - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] 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`.
GiteaMirror added the issue/confirmedtype/bug labels 2025-11-02 06:21:39 -06:00
Author
Owner

@stale[bot] commented on GitHub (Jun 28, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Jun 28, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@CirnoT commented on GitHub (Jun 28, 2020):

Bad bot

@CirnoT commented on GitHub (Jun 28, 2020): Bad bot
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5326