summaryrefslogtreecommitdiffstats
path: root/api/admin.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-05-03 14:45:36 -0400
committerChristopher Speller <crspeller@gmail.com>2016-05-03 14:45:36 -0400
commitb18cf58c8f607bed64d821fcc856e251a391df6a (patch)
tree7315a3f82a9de07fd3dd5ca0b83ddb912f87d5aa /api/admin.go
parent87989b8afd4666a72940389db716b6500d0a9ec3 (diff)
downloadchat-b18cf58c8f607bed64d821fcc856e251a391df6a.tar.gz
chat-b18cf58c8f607bed64d821fcc856e251a391df6a.tar.bz2
chat-b18cf58c8f607bed64d821fcc856e251a391df6a.zip
Sanitize sensitive data of out config file for the system console (#2849)
Diffstat (limited to 'api/admin.go')
-rw-r--r--api/admin.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/api/admin.go b/api/admin.go
index 930170619..7ab2c9cfc 100644
--- a/api/admin.go
+++ b/api/admin.go
@@ -127,10 +127,11 @@ func getConfig(c *Context, w http.ResponseWriter, r *http.Request) {
json := utils.Cfg.ToJson()
cfg := model.ConfigFromJson(strings.NewReader(json))
- json = cfg.ToJson()
+
+ cfg.Sanitize()
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
- w.Write([]byte(json))
+ w.Write([]byte(cfg.ToJson()))
}
func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -145,6 +146,7 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
}
cfg.SetDefaults()
+ utils.Desanitize(cfg)
if err := cfg.IsValid(); err != nil {
c.Err = err
@@ -160,8 +162,10 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
utils.SaveConfig(utils.CfgFileName, cfg)
utils.LoadConfig(utils.CfgFileName)
- json := utils.Cfg.ToJson()
- w.Write([]byte(json))
+
+ rdata := map[string]string{}
+ rdata["status"] = "OK"
+ w.Write([]byte(model.MapToJson(rdata)))
}
func testEmail(c *Context, w http.ResponseWriter, r *http.Request) {