summaryrefslogtreecommitdiffstats
path: root/app/license.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-06-19 13:46:51 -0400
committerChristopher Speller <crspeller@gmail.com>2017-06-19 10:46:51 -0700
commit1d66e64e54c59ea9184bd614790498451d025e25 (patch)
tree605353f462cde5eac7c36bec4a4b7d05e6fede2b /app/license.go
parent59088a1687b999e40d7468ad27997d2ec78a294e (diff)
downloadchat-1d66e64e54c59ea9184bd614790498451d025e25.tar.gz
chat-1d66e64e54c59ea9184bd614790498451d025e25.tar.bz2
chat-1d66e64e54c59ea9184bd614790498451d025e25.zip
Add POST and DELETE /license endpoints for v4 (#6665)
* Add POST and DELETE /license endpoints for v4 * Fix comment text
Diffstat (limited to 'app/license.go')
-rw-r--r--app/license.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/license.go b/app/license.go
index 44b700d5b..8cb76fd6e 100644
--- a/app/license.go
+++ b/app/license.go
@@ -4,6 +4,7 @@
package app
import (
+ "net/http"
"strings"
l4g "github.com/alecthomas/log4go"
@@ -49,17 +50,17 @@ func SaveLicense(licenseBytes []byte) (*model.License, *model.AppError) {
license = model.LicenseFromJson(strings.NewReader(licenseStr))
if result := <-Srv.Store.User().AnalyticsUniqueUserCount(""); result.Err != nil {
- return nil, model.NewLocAppError("addLicense", "api.license.add_license.invalid_count.app_error", nil, result.Err.Error())
+ return nil, model.NewAppError("addLicense", "api.license.add_license.invalid_count.app_error", nil, result.Err.Error(), http.StatusBadRequest)
} else {
uniqueUserCount := result.Data.(int64)
if uniqueUserCount > int64(*license.Features.Users) {
- return nil, model.NewLocAppError("addLicense", "api.license.add_license.unique_users.app_error", map[string]interface{}{"Users": *license.Features.Users, "Count": uniqueUserCount}, "")
+ return nil, model.NewAppError("addLicense", "api.license.add_license.unique_users.app_error", map[string]interface{}{"Users": *license.Features.Users, "Count": uniqueUserCount}, "", http.StatusBadRequest)
}
}
if ok := utils.SetLicense(license); !ok {
- return nil, model.NewLocAppError("addLicense", model.EXPIRED_LICENSE_ERROR, nil, "")
+ return nil, model.NewAppError("addLicense", model.EXPIRED_LICENSE_ERROR, nil, "", http.StatusBadRequest)
}
record := &model.LicenseRecord{}
@@ -69,7 +70,7 @@ func SaveLicense(licenseBytes []byte) (*model.License, *model.AppError) {
if result := <-rchan; result.Err != nil {
RemoveLicense()
- return nil, model.NewLocAppError("addLicense", "api.license.add_license.save.app_error", nil, "err="+result.Err.Error())
+ return nil, model.NewAppError("addLicense", "api.license.add_license.save.app_error", nil, "err="+result.Err.Error(), http.StatusInternalServerError)
}
sysVar := &model.System{}
@@ -79,10 +80,10 @@ func SaveLicense(licenseBytes []byte) (*model.License, *model.AppError) {
if result := <-schan; result.Err != nil {
RemoveLicense()
- return nil, model.NewLocAppError("addLicense", "api.license.add_license.save_active.app_error", nil, "")
+ return nil, model.NewAppError("addLicense", "api.license.add_license.save_active.app_error", nil, "", http.StatusInternalServerError)
}
} else {
- return nil, model.NewLocAppError("addLicense", model.INVALID_LICENSE_ERROR, nil, "")
+ return nil, model.NewAppError("addLicense", model.INVALID_LICENSE_ERROR, nil, "", http.StatusBadRequest)
}
ReloadConfig()