mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 10:18:38 +00:00
#1525 Triggere mailer for admin created accounts
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/mailer"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
@@ -60,6 +61,8 @@ func NewUser(ctx *middleware.Context) {
|
||||
return
|
||||
}
|
||||
ctx.Data["Sources"] = sources
|
||||
|
||||
ctx.Data["CanSendEmail"] = setting.MailService != nil
|
||||
ctx.HTML(200, USER_NEW)
|
||||
}
|
||||
|
||||
@@ -75,6 +78,8 @@ func NewUserPost(ctx *middleware.Context, form auth.AdminCrateUserForm) {
|
||||
}
|
||||
ctx.Data["Sources"] = sources
|
||||
|
||||
ctx.Data["CanSendEmail"] = setting.MailService != nil
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, USER_NEW)
|
||||
return
|
||||
@@ -118,6 +123,11 @@ func NewUserPost(ctx *middleware.Context, form auth.AdminCrateUserForm) {
|
||||
}
|
||||
log.Trace("Account created by admin(%s): %s", ctx.User.Name, u.Name)
|
||||
|
||||
// Send e-mail notification.
|
||||
if form.SendNotify && setting.MailService != nil {
|
||||
mailer.SendRegisterNotifyMail(ctx.Context, u)
|
||||
}
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("admin.users.new_success", u.Name))
|
||||
ctx.Redirect(setting.AppSubUrl + "/admin/users/" + com.ToStr(u.Id))
|
||||
}
|
||||
|
Reference in New Issue
Block a user