From bff2b5e735ae7fc80157b4108ddbe56be8acb752 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 9 Oct 2017 14:59:48 -0700 Subject: Miscellaneous app cleanup (#7594) * app cleanup * whoops, forgot a file * some minor cleanup * longer container deadline * defensive checks --- app/oauth.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'app/oauth.go') diff --git a/app/oauth.go b/app/oauth.go index 6e411138b..909d16628 100644 --- a/app/oauth.go +++ b/app/oauth.go @@ -7,7 +7,6 @@ import ( "bytes" b64 "encoding/base64" "io" - "io/ioutil" "net/http" "net/url" "strings" @@ -428,10 +427,7 @@ func (a *App) RevokeAccessToken(token string) *model.AppError { } func (a *App) CompleteOAuth(service string, body io.ReadCloser, teamId string, props map[string]string) (*model.User, *model.AppError) { - defer func() { - ioutil.ReadAll(body) - body.Close() - }() + defer body.Close() action := props["action"] @@ -688,11 +684,9 @@ func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service if resp, err := utils.HttpClient(true).Do(req); err != nil { return nil, "", stateProps, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.token_failed.app_error", nil, err.Error(), http.StatusInternalServerError) } else { - bodyBytes, _ = ioutil.ReadAll(resp.Body) - resp.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes)) - ar = model.AccessResponseFromJson(resp.Body) - defer CloseBody(resp) + resp.Body.Close() + if ar == nil { return nil, "", stateProps, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, "response_body="+string(bodyBytes), http.StatusInternalServerError) } -- cgit v1.2.3-1-g7c22