aboutsummaryrefslogtreecommitdiffstats
path: root/routers/admin
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-09-25 19:45:44 -0400
committerUnknwon <u@gogs.io>2015-09-25 19:45:44 -0400
commit21e13cb51e73471d186b963e26404f89abd81fce (patch)
tree9dfcbb3f446321066d2e49feb3b71b99d1c6bdca /routers/admin
parent986447335dd4057003b2715034948e87a47bed6b (diff)
downloadgitea-21e13cb51e73471d186b963e26404f89abd81fce.tar.gz
gitea-21e13cb51e73471d186b963e26404f89abd81fce.zip
#1525 Triggere mailer for admin created accounts
Diffstat (limited to 'routers/admin')
-rw-r--r--routers/admin/users.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/routers/admin/users.go b/routers/admin/users.go
index 4302c1443b..ac0f538171 100644
--- a/routers/admin/users.go
+++ b/routers/admin/users.go
@@ -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))
}