From 0ca5adee16a9de0fb0bd410aa841eeeda3372e23 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 10 May 2023 18:49:47 +0800 Subject: [PATCH] Do not send "registration success email" for external auth sources (#24632) Co-author: @pboguslawski "registration success email" is only used for notifying a user that "you have a new account now" when the account is created by admin manually. When a user uses external auth source, they already knows that they has the account, so do not send such email. Co-authored-by: Giteabot --- services/auth/reverseproxy.go | 3 --- services/auth/source/ldap/source_authenticate.go | 3 --- services/auth/source/pam/source_authenticate.go | 3 --- services/auth/source/smtp/source_authenticate.go | 3 --- services/auth/sspi_windows.go | 3 --- 5 files changed, 15 deletions(-) diff --git a/services/auth/reverseproxy.go b/services/auth/reverseproxy.go index 91acff90cc..3574e660b8 100644 --- a/services/auth/reverseproxy.go +++ b/services/auth/reverseproxy.go @@ -13,7 +13,6 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web/middleware" - "code.gitea.io/gitea/services/mailer" gouuid "github.com/google/uuid" ) @@ -172,7 +171,5 @@ func (r *ReverseProxy) newUser(req *http.Request) *user_model.User { return nil } - mailer.SendRegisterNotifyMail(user) - return user } diff --git a/services/auth/source/ldap/source_authenticate.go b/services/auth/source/ldap/source_authenticate.go index fba8da7934..89e99b5e60 100644 --- a/services/auth/source/ldap/source_authenticate.go +++ b/services/auth/source/ldap/source_authenticate.go @@ -14,7 +14,6 @@ import ( auth_module "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/util" source_service "code.gitea.io/gitea/services/auth/source" - "code.gitea.io/gitea/services/mailer" user_service "code.gitea.io/gitea/services/user" ) @@ -100,8 +99,6 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str return user, err } - mailer.SendRegisterNotifyMail(user) - if isAttributeSSHPublicKeySet && asymkey_model.AddPublicKeysBySource(user, source.authSource, sr.SSHPublicKey) { if err := asymkey_model.RewriteAllPublicKeys(); err != nil { return user, err diff --git a/services/auth/source/pam/source_authenticate.go b/services/auth/source/pam/source_authenticate.go index 48cd905a0a..e3a74e495c 100644 --- a/services/auth/source/pam/source_authenticate.go +++ b/services/auth/source/pam/source_authenticate.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/modules/auth/pam" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - "code.gitea.io/gitea/services/mailer" "github.com/google/uuid" ) @@ -67,8 +66,6 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str return user, err } - mailer.SendRegisterNotifyMail(user) - return user, nil } diff --git a/services/auth/source/smtp/source_authenticate.go b/services/auth/source/smtp/source_authenticate.go index 36b351198a..7d7d1aa8b6 100644 --- a/services/auth/source/smtp/source_authenticate.go +++ b/services/auth/source/smtp/source_authenticate.go @@ -12,7 +12,6 @@ import ( auth_model "code.gitea.io/gitea/models/auth" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/util" - "code.gitea.io/gitea/services/mailer" ) // Authenticate queries if the provided login/password is authenticates against the SMTP server @@ -82,8 +81,6 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str return user, err } - mailer.SendRegisterNotifyMail(user) - return user, nil } diff --git a/services/auth/sspi_windows.go b/services/auth/sspi_windows.go index 176f4f574f..d49497e19c 100644 --- a/services/auth/sspi_windows.go +++ b/services/auth/sspi_windows.go @@ -19,7 +19,6 @@ import ( "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web/middleware" "code.gitea.io/gitea/services/auth/source/sspi" - "code.gitea.io/gitea/services/mailer" gouuid "github.com/google/uuid" "github.com/quasoft/websspi" @@ -191,8 +190,6 @@ func (s *SSPI) newUser(username string, cfg *sspi.Source) (*user_model.User, err return nil, err } - mailer.SendRegisterNotifyMail(user) - return user, nil }