diff options
Diffstat (limited to 'services/auth')
-rw-r--r-- | services/auth/reverseproxy.go | 3 | ||||
-rw-r--r-- | services/auth/source/ldap/source_authenticate.go | 8 | ||||
-rw-r--r-- | services/auth/source/pam/source_authenticate.go | 10 | ||||
-rw-r--r-- | services/auth/source/smtp/source_authenticate.go | 10 | ||||
-rw-r--r-- | services/auth/sspi_windows.go | 4 |
5 files changed, 32 insertions, 3 deletions
diff --git a/services/auth/reverseproxy.go b/services/auth/reverseproxy.go index 46d8d3fa63..7ff226077c 100644 --- a/services/auth/reverseproxy.go +++ b/services/auth/reverseproxy.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web/middleware" + "code.gitea.io/gitea/services/mailer" gouuid "github.com/google/uuid" ) @@ -112,5 +113,7 @@ func (r *ReverseProxy) newUser(req *http.Request) *models.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 1d5e69539b..ecc95fbd56 100644 --- a/services/auth/source/ldap/source_authenticate.go +++ b/services/auth/source/ldap/source_authenticate.go @@ -9,6 +9,7 @@ import ( "strings" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/services/mailer" ) // Authenticate queries if login/password is valid against the LDAP directory pool, @@ -84,8 +85,13 @@ func (source *Source) Authenticate(user *models.User, login, password string) (* } err := models.CreateUser(user) + if err != nil { + return user, err + } + + mailer.SendRegisterNotifyMail(user) - if err == nil && isAttributeSSHPublicKeySet && models.AddPublicKeysBySource(user, source.loginSource, sr.SSHPublicKey) { + if isAttributeSSHPublicKeySet && models.AddPublicKeysBySource(user, source.loginSource, sr.SSHPublicKey) { err = models.RewriteAllPublicKeys() } diff --git a/services/auth/source/pam/source_authenticate.go b/services/auth/source/pam/source_authenticate.go index 6ca0642904..8241aed725 100644 --- a/services/auth/source/pam/source_authenticate.go +++ b/services/auth/source/pam/source_authenticate.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth/pam" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/services/mailer" "github.com/google/uuid" ) @@ -58,5 +59,12 @@ func (source *Source) Authenticate(user *models.User, login, password string) (* LoginName: login, // This is what the user typed in IsActive: true, } - return user, models.CreateUser(user) + + if err := models.CreateUser(user); err != nil { + 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 e3dcd83222..cff64c69d2 100644 --- a/services/auth/source/smtp/source_authenticate.go +++ b/services/auth/source/smtp/source_authenticate.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/models" "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 @@ -74,5 +75,12 @@ func (source *Source) Authenticate(user *models.User, login, password string) (* LoginName: login, IsActive: true, } - return user, models.CreateUser(user) + + if err := models.CreateUser(user); err != nil { + return user, err + } + + mailer.SendRegisterNotifyMail(user) + + return user, nil } diff --git a/services/auth/sspi_windows.go b/services/auth/sspi_windows.go index 8420d43071..d7e0f55242 100644 --- a/services/auth/sspi_windows.go +++ b/services/auth/sspi_windows.go @@ -16,6 +16,7 @@ import ( "code.gitea.io/gitea/modules/templates" "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" @@ -197,6 +198,9 @@ func (s *SSPI) newUser(username string, cfg *sspi.Source) (*models.User, error) if err := models.CreateUser(user); err != nil { return nil, err } + + mailer.SendRegisterNotifyMail(user) + return user, nil } |