#1525 Triggere mailer for admin created accounts
This commit is contained in:
parent
986447335d
commit
21e13cb51e
11 changed files with 213 additions and 191 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue