aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-02-25 02:07:52 +0800
committerGitHub <noreply@github.com>2022-02-24 19:07:52 +0100
commit3685cc7660e968f9674087dfa213be5a78247f0d (patch)
tree31f0a9a3c456949fbacfb4e690bdb1b0112f093b /services
parent9d9ccdbe434992d21b418eefae0ecc32a5f22b14 (diff)
downloadgitea-3685cc7660e968f9674087dfa213be5a78247f0d.tar.gz
gitea-3685cc7660e968f9674087dfa213be5a78247f0d.zip
Fix ldap user sync missed email in email_address table (#18786) (#18876)
* Fix ldap user sync missed email in email_address table (#18786)
Diffstat (limited to 'services')
-rw-r--r--services/auth/source/ldap/source_sync.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/services/auth/source/ldap/source_sync.go b/services/auth/source/ldap/source_sync.go
index 78aa90aaa5..a7f06fcc9e 100644
--- a/services/auth/source/ldap/source_sync.go
+++ b/services/auth/source/ldap/source_sync.go
@@ -143,6 +143,7 @@ func (source *Source) Sync(ctx context.Context, updateExisting bool) error {
log.Trace("SyncExternalUsers[%s]: Updating user %s", source.authSource.Name, usr.Name)
usr.FullName = fullName
+ emailChanged := usr.Email != su.Mail
usr.Email = su.Mail
// Change existing admin flag only if AdminFilter option is set
if len(source.AdminFilter) > 0 {
@@ -154,7 +155,7 @@ func (source *Source) Sync(ctx context.Context, updateExisting bool) error {
}
usr.IsActive = true
- err = user_model.UpdateUserCols(db.DefaultContext, usr, "full_name", "email", "is_admin", "is_restricted", "is_active")
+ err = user_model.UpdateUser(usr, emailChanged, "full_name", "email", "is_admin", "is_restricted", "is_active")
if err != nil {
log.Error("SyncExternalUsers[%s]: Error updating user %s: %v", source.authSource.Name, usr.Name, err)
}