Inconsistent e-mail address sync from LDAP #8496

Closed
opened 2025-11-02 08:08:41 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @pboguslawski on GitHub (Feb 4, 2022).

Gitea Version

1.16-rc1

Git Version

No response

Operating System

No response

How are you running Gitea?

Compiled from source.

Database

No response

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Description

According to

https://github.com/go-gitea/gitea/issues/4497#issuecomment-459057141

LDAP sync cron task synchronizes only primary user mail; current sync code

https://github.com/go-gitea/gitea/blob/main/services/auth/source/ldap/source_sync.go#L157

updates only email column in user table and does not update extra e-mails nor is_primary state in this table.

There should be separate new method called there for consistent updating user primary e-mail (i.e. in users table and extra emails table with is_primary updating). LDAP should not add changed e-mail as new e-mail (like manual changing user email in admin panel does after https://github.com/go-gitea/gitea/pull/17549) but should update current primary e-mail only like it was working in gitea 1.13.

Same solution should be applied to LDAP sync code on user login if https://github.com/go-gitea/gitea/pull/18452#issuecomment-1029806729 is merged.

To be considered: separate storing user primary e-mail in two separate tables is error prone. It should be kept in only one place problably to avoid such bugs.

Screenshots

No response

Originally created by @pboguslawski on GitHub (Feb 4, 2022). ### Gitea Version 1.16-rc1 ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Compiled from source. ### Database _No response_ ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Description According to https://github.com/go-gitea/gitea/issues/4497#issuecomment-459057141 LDAP sync cron task synchronizes only primary user mail; current sync code https://github.com/go-gitea/gitea/blob/main/services/auth/source/ldap/source_sync.go#L157 updates only email column in user table and does not update extra e-mails nor is_primary state in this table. There should be separate new method called there for consistent updating user primary e-mail (i.e. in users table and extra emails table with is_primary updating). LDAP should not add changed e-mail as new e-mail (like manual changing user email in admin panel does after https://github.com/go-gitea/gitea/pull/17549) but should update current primary e-mail only like it was working in gitea 1.13. Same solution should be applied to LDAP sync code on user login if https://github.com/go-gitea/gitea/pull/18452#issuecomment-1029806729 is merged. To be considered: separate storing user primary e-mail in two separate tables is error prone. It should be kept in only one place problably to avoid such bugs. ### Screenshots _No response_
GiteaMirror added the type/bug label 2025-11-02 08:08:41 -06:00
Author
Owner

@lunny commented on GitHub (Feb 16, 2022):

The email in the user table should be deleted in future PRs.

@lunny commented on GitHub (Feb 16, 2022): The email in the user table should be deleted in future PRs.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8496