diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/license.go | 2 | ||||
-rw-r--r-- | api/team.go | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/api/license.go b/api/license.go index 06d4aa3a7..a6a167cac 100644 --- a/api/license.go +++ b/api/license.go @@ -45,11 +45,11 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) { fileData := fileArray[0] file, err := fileData.Open() - defer file.Close() if err != nil { c.Err = model.NewAppError("addLicense", "api.license.add_license.open.app_error", nil, err.Error(), http.StatusInternalServerError) return } + defer file.Close() buf := bytes.NewBuffer(nil) io.Copy(buf, file) diff --git a/api/team.go b/api/team.go index 7f53786d9..089680624 100644 --- a/api/team.go +++ b/api/team.go @@ -386,10 +386,14 @@ func importTeam(c *Context, w http.ResponseWriter, r *http.Request) { } importFromArray, ok := r.MultipartForm.Value["importFrom"] + if !ok || len(importFromArray) < 1 { + c.Err = model.NewAppError("importTeam", "api.team.import_team.no_import_from.app_error", nil, "", http.StatusBadRequest) + return + } importFrom := importFromArray[0] fileSizeStr, ok := r.MultipartForm.Value["filesize"] - if !ok { + if !ok || len(fileSizeStr) < 1 { c.Err = model.NewAppError("importTeam", "api.team.import_team.unavailable.app_error", nil, "", http.StatusBadRequest) return } @@ -414,11 +418,11 @@ func importTeam(c *Context, w http.ResponseWriter, r *http.Request) { fileInfo := fileInfoArray[0] fileData, err := fileInfo.Open() - defer fileData.Close() if err != nil { c.Err = model.NewAppError("importTeam", "api.team.import_team.open.app_error", nil, err.Error(), http.StatusBadRequest) return } + defer fileData.Close() var log *bytes.Buffer switch importFrom { |