1
0
Fork 0
forked from forgejo/forgejo

Send registration email on user autoregistration (#16523)

When users login and are autoregistered send email notification.

Fix #16178

* Protect public functions within the mailer by testing if the mailer is configured

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
zeripath 2021-08-12 08:26:33 +01:00 committed by GitHub
parent e29e163737
commit 162c32af7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 88 additions and 3 deletions

View file

@ -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
}
if err == nil && isAttributeSSHPublicKeySet && models.AddPublicKeysBySource(user, source.loginSource, sr.SSHPublicKey) {
mailer.SendRegisterNotifyMail(user)
if isAttributeSSHPublicKeySet && models.AddPublicKeysBySource(user, source.loginSource, sr.SSHPublicKey) {
err = models.RewriteAllPublicKeys()
}