Skip to content

Commit 0ca5ade

Browse files
wxiaoguangGiteaBot
andauthored
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 <teabot@gitea.io>
1 parent 35ab5cd commit 0ca5ade

File tree

5 files changed

+0
-15
lines changed

5 files changed

+0
-15
lines changed

services/auth/reverseproxy.go

-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"code.gitea.io/gitea/modules/setting"
1414
"code.gitea.io/gitea/modules/util"
1515
"code.gitea.io/gitea/modules/web/middleware"
16-
"code.gitea.io/gitea/services/mailer"
1716

1817
gouuid "github.com/google/uuid"
1918
)
@@ -172,7 +171,5 @@ func (r *ReverseProxy) newUser(req *http.Request) *user_model.User {
172171
return nil
173172
}
174173

175-
mailer.SendRegisterNotifyMail(user)
176-
177174
return user
178175
}

services/auth/source/ldap/source_authenticate.go

-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
auth_module "code.gitea.io/gitea/modules/auth"
1515
"code.gitea.io/gitea/modules/util"
1616
source_service "code.gitea.io/gitea/services/auth/source"
17-
"code.gitea.io/gitea/services/mailer"
1817
user_service "code.gitea.io/gitea/services/user"
1918
)
2019

@@ -100,8 +99,6 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str
10099
return user, err
101100
}
102101

103-
mailer.SendRegisterNotifyMail(user)
104-
105102
if isAttributeSSHPublicKeySet && asymkey_model.AddPublicKeysBySource(user, source.authSource, sr.SSHPublicKey) {
106103
if err := asymkey_model.RewriteAllPublicKeys(); err != nil {
107104
return user, err

services/auth/source/pam/source_authenticate.go

-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"code.gitea.io/gitea/modules/auth/pam"
1313
"code.gitea.io/gitea/modules/setting"
1414
"code.gitea.io/gitea/modules/util"
15-
"code.gitea.io/gitea/services/mailer"
1615

1716
"github.com/google/uuid"
1817
)
@@ -67,8 +66,6 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str
6766
return user, err
6867
}
6968

70-
mailer.SendRegisterNotifyMail(user)
71-
7269
return user, nil
7370
}
7471

services/auth/source/smtp/source_authenticate.go

-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
auth_model "code.gitea.io/gitea/models/auth"
1313
user_model "code.gitea.io/gitea/models/user"
1414
"code.gitea.io/gitea/modules/util"
15-
"code.gitea.io/gitea/services/mailer"
1615
)
1716

1817
// 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
8281
return user, err
8382
}
8483

85-
mailer.SendRegisterNotifyMail(user)
86-
8784
return user, nil
8885
}
8986

services/auth/sspi_windows.go

-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"code.gitea.io/gitea/modules/util"
2020
"code.gitea.io/gitea/modules/web/middleware"
2121
"code.gitea.io/gitea/services/auth/source/sspi"
22-
"code.gitea.io/gitea/services/mailer"
2322

2423
gouuid "github.com/google/uuid"
2524
"github.com/quasoft/websspi"
@@ -191,8 +190,6 @@ func (s *SSPI) newUser(username string, cfg *sspi.Source) (*user_model.User, err
191190
return nil, err
192191
}
193192

194-
mailer.SendRegisterNotifyMail(user)
195-
196193
return user, nil
197194
}
198195

0 commit comments

Comments
 (0)