From 1d66e64e54c59ea9184bd614790498451d025e25 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 19 Jun 2017 13:46:51 -0400 Subject: Add POST and DELETE /license endpoints for v4 (#6665) * Add POST and DELETE /license endpoints for v4 * Fix comment text --- app/license.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'app/license.go') 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() -- cgit v1.2.3-1-g7c22