summaryrefslogtreecommitdiffstats
path: root/api/license.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2016-01-14 08:23:48 -0500
committerJoramWilander <jwawilander@gmail.com>2016-01-14 08:24:09 -0500
commitc26edcf6786fd8aa1535c09e9581fc6417cddda4 (patch)
treed8283b12c2a1b14c18da4ae446f5c2ca0e5d0af5 /api/license.go
parent22c522178ce5a4b9e9533d91dd77518a2899f2b0 (diff)
downloadchat-c26edcf6786fd8aa1535c09e9581fc6417cddda4.tar.gz
chat-c26edcf6786fd8aa1535c09e9581fc6417cddda4.tar.bz2
chat-c26edcf6786fd8aa1535c09e9581fc6417cddda4.zip
Final updates
Diffstat (limited to 'api/license.go')
-rw-r--r--api/license.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/api/license.go b/api/license.go
index 9ed2d2afb..06bde2b6c 100644
--- a/api/license.go
+++ b/api/license.go
@@ -69,14 +69,15 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- go func() {
- if err := writeFileLocally(data, utils.LICENSE_FILE_LOC); err != nil {
- l4g.Error("Could not save license file")
- }
- }()
+ if err := writeFileLocally(data, utils.LicenseLocation()); err != nil {
+ c.LogAudit("failed - could not save license file")
+ c.Err = model.NewAppError("addLicense", "License did not save properly.", "path="+utils.LicenseLocation())
+ utils.RemoveLicense()
+ return
+ }
} else {
c.LogAudit("failed - invalid license")
- c.Err = model.NewAppError("addLicense", "Invalid license file", "")
+ c.Err = model.NewAppError("addLicense", "Invalid license file.", "")
return
}
@@ -87,7 +88,11 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
func removeLicense(c *Context, w http.ResponseWriter, r *http.Request) {
c.LogAudit("")
- utils.RemoveLicense()
+ if ok := utils.RemoveLicense(); !ok {
+ c.LogAudit("failed - could not remove license file")
+ c.Err = model.NewAppError("removeLicense", "License did not remove properly.", "")
+ return
+ }
rdata := map[string]string{}
rdata["status"] = "ok"