summaryrefslogtreecommitdiffstats
path: root/api/admin.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-09-21 15:11:56 -0700
committer=Corey Hulen <corey@hulen.com>2015-09-21 15:11:56 -0700
commited9a2da83b3b77e7dd0314eaa92082ac8a2a9a9c (patch)
tree3c890327d884b33ad149196ddf9879313b2b000b /api/admin.go
parentee5a77ec56ee13f5eb96fce6065b4b7a1845de89 (diff)
downloadchat-ed9a2da83b3b77e7dd0314eaa92082ac8a2a9a9c.tar.gz
chat-ed9a2da83b3b77e7dd0314eaa92082ac8a2a9a9c.tar.bz2
chat-ed9a2da83b3b77e7dd0314eaa92082ac8a2a9a9c.zip
Adding email to admin console
Diffstat (limited to 'api/admin.go')
-rw-r--r--api/admin.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/api/admin.go b/api/admin.go
index 646597755..ca66b7cb4 100644
--- a/api/admin.go
+++ b/api/admin.go
@@ -24,6 +24,7 @@ func InitAdmin(r *mux.Router) {
sr.Handle("/config", ApiUserRequired(getConfig)).Methods("GET")
sr.Handle("/save_config", ApiUserRequired(saveConfig)).Methods("POST")
sr.Handle("/client_props", ApiAppHandler(getClientProperties)).Methods("GET")
+ sr.Handle("/test_email", ApiUserRequired(testEmail)).Methods("POST")
}
func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -98,3 +99,29 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
json := utils.Cfg.ToJson()
w.Write([]byte(json))
}
+
+func testEmail(c *Context, w http.ResponseWriter, r *http.Request) {
+ if !c.HasSystemAdminPermissions("testEmail") {
+ return
+ }
+
+ cfg := model.ConfigFromJson(r.Body)
+ if cfg == nil {
+ c.SetInvalidParam("testEmail", "config")
+ return
+ }
+
+ if result := <-Srv.Store.User().Get(c.Session.UserId); result.Err != nil {
+ c.Err = result.Err
+ return
+ } else {
+ if err := utils.SendMailUsingConfig(result.Data.(*model.User).Email, "Mattermost - Testing Email Settings", "<br/><br/><br/>It appears your Mattermost email is setup correctly!", cfg); err != nil {
+ c.Err = err
+ return
+ }
+ }
+
+ m := make(map[string]string)
+ m["SUCCESS"] = "true"
+ w.Write([]byte(model.MapToJson(m)))
+}