diff options
author | Corey Hulen <corey@hulen.com> | 2016-02-04 13:01:14 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-02-04 13:01:14 -0800 |
commit | af6ade338002a215ff7c7771f7fe6bbbb06f0cd7 (patch) | |
tree | a8e696aaaf8fd4e483d52f356e848aafcf2a6c25 /api/license.go | |
parent | ec51c31c325b3dc648a261f0e8634b6d70d7ba73 (diff) | |
parent | e45282deaa1d78d7ff3a125e9fd11e3fdc120b07 (diff) | |
download | chat-af6ade338002a215ff7c7771f7fe6bbbb06f0cd7.tar.gz chat-af6ade338002a215ff7c7771f7fe6bbbb06f0cd7.tar.bz2 chat-af6ade338002a215ff7c7771f7fe6bbbb06f0cd7.zip |
Merge pull request #2073 from mattermost/ee-updates
Some general updates to EE
Diffstat (limited to 'api/license.go')
-rw-r--r-- | api/license.go | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/api/license.go b/api/license.go index 4077c0e46..23e7946c8 100644 --- a/api/license.go +++ b/api/license.go @@ -81,9 +81,24 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) { return } - if err := writeFileLocally(data, utils.LicenseLocation()); err != nil { - c.LogAudit("failed - could not save license file") - c.Err = model.NewLocAppError("addLicense", "api.license.add_license.save.app_error", nil, "path="+utils.LicenseLocation()) + record := &model.LicenseRecord{} + record.Id = license.Id + record.Bytes = string(data) + rchan := Srv.Store.License().Save(record) + + sysVar := &model.System{} + sysVar.Name = model.SYSTEM_ACTIVE_LICENSE_ID + sysVar.Value = license.Id + schan := Srv.Store.System().SaveOrUpdate(sysVar) + + if result := <-rchan; result.Err != nil { + c.Err = model.NewLocAppError("addLicense", "api.license.add_license.save.app_error", nil, "err="+result.Err.Error()) + utils.RemoveLicense() + return + } + + if result := <-schan; result.Err != nil { + c.Err = model.NewLocAppError("addLicense", "api.license.add_license.save_active.app_error", nil, "") utils.RemoveLicense() return } @@ -100,9 +115,14 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) { func removeLicense(c *Context, w http.ResponseWriter, r *http.Request) { c.LogAudit("") - if ok := utils.RemoveLicense(); !ok { - c.LogAudit("failed - could not remove license file") - c.Err = model.NewLocAppError("removeLicense", "api.license.remove_license.remove.app_error", nil, "") + utils.RemoveLicense() + + sysVar := &model.System{} + sysVar.Name = model.SYSTEM_ACTIVE_LICENSE_ID + sysVar.Value = "" + + if result := <-Srv.Store.System().Update(sysVar); result.Err != nil { + c.Err = model.NewLocAppError("removeLicense", "api.license.remove_license.update.app_error", nil, "") return } |