Add more debugging info to server logs for failed OAuth requests (#7039)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
2c5eefa17a
Коммит
4d45214394
11
app/oauth.go
11
app/oauth.go
@@ -672,23 +672,26 @@ func AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, s
|
|||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
|
|
||||||
var ar *model.AccessResponse
|
var ar *model.AccessResponse
|
||||||
var respBody []byte
|
var bodyBytes []byte
|
||||||
if resp, err := utils.HttpClient().Do(req); err != nil {
|
if resp, err := utils.HttpClient().Do(req); err != nil {
|
||||||
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.token_failed.app_error", nil, err.Error())
|
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.token_failed.app_error", nil, err.Error())
|
||||||
} else {
|
} else {
|
||||||
|
bodyBytes, _ = ioutil.ReadAll(resp.Body)
|
||||||
|
resp.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))
|
||||||
|
|
||||||
ar = model.AccessResponseFromJson(resp.Body)
|
ar = model.AccessResponseFromJson(resp.Body)
|
||||||
defer CloseBody(resp)
|
defer CloseBody(resp)
|
||||||
if ar == nil {
|
if ar == nil {
|
||||||
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, "")
|
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, "response_body="+string(bodyBytes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.ToLower(ar.TokenType) != model.ACCESS_TOKEN_TYPE {
|
if strings.ToLower(ar.TokenType) != model.ACCESS_TOKEN_TYPE {
|
||||||
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_token.app_error", nil, "token_type="+ar.TokenType+", response_body="+string(respBody))
|
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_token.app_error", nil, "token_type="+ar.TokenType+", response_body="+string(bodyBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ar.AccessToken) == 0 {
|
if len(ar.AccessToken) == 0 {
|
||||||
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.missing.app_error", nil, "")
|
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.missing.app_error", nil, "response_body="+string(bodyBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
p = url.Values{}
|
p = url.Values{}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user