summaryrefslogtreecommitdiffstats
path: root/app/oauth.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-09-01 16:42:02 +0100
committerHarrison Healey <harrisonmhealey@gmail.com>2017-09-01 11:42:02 -0400
commite85b5fb98835fb952eb2ed55f81e79eb3ef361ec (patch)
treeabe78804cd5e1175954f74b811a6d6a7af089d0b /app/oauth.go
parentd9ec7d9240a508571904c22458222e2846c2b5b4 (diff)
downloadchat-e85b5fb98835fb952eb2ed55f81e79eb3ef361ec.tar.gz
chat-e85b5fb98835fb952eb2ed55f81e79eb3ef361ec.tar.bz2
chat-e85b5fb98835fb952eb2ed55f81e79eb3ef361ec.zip
App: NewLocAppError -> NewAppError (#7327)
* App: NewLocAppError -> NewAppError * Remove statuscode that got missed.
Diffstat (limited to 'app/oauth.go')
-rw-r--r--app/oauth.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/app/oauth.go b/app/oauth.go
index f8ddc6076..b2bedb63b 100644
--- a/app/oauth.go
+++ b/app/oauth.go
@@ -395,17 +395,17 @@ func RevokeAccessToken(token string) *model.AppError {
schan := Srv.Store.Session().Remove(token)
if result := <-Srv.Store.OAuth().GetAccessData(token); result.Err != nil {
- return model.NewLocAppError("RevokeAccessToken", "api.oauth.revoke_access_token.get.app_error", nil, "")
+ return model.NewAppError("RevokeAccessToken", "api.oauth.revoke_access_token.get.app_error", nil, "", http.StatusBadRequest)
}
tchan := Srv.Store.OAuth().RemoveAccessData(token)
if result := <-tchan; result.Err != nil {
- return model.NewLocAppError("RevokeAccessToken", "api.oauth.revoke_access_token.del_token.app_error", nil, "")
+ return model.NewAppError("RevokeAccessToken", "api.oauth.revoke_access_token.del_token.app_error", nil, "", http.StatusInternalServerError)
}
if result := <-schan; result.Err != nil {
- return model.NewLocAppError("RevokeAccessToken", "api.oauth.revoke_access_token.del_session.app_error", nil, "")
+ return model.NewAppError("RevokeAccessToken", "api.oauth.revoke_access_token.del_session.app_error", nil, "", http.StatusInternalServerError)
}
if session != nil {
@@ -610,12 +610,12 @@ func GetAuthorizationCode(w http.ResponseWriter, r *http.Request, service string
func AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, state, redirectUri string) (io.ReadCloser, string, map[string]string, *model.AppError) {
sso := utils.Cfg.GetSSOService(service)
if sso == nil || !sso.Enable {
- return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.unsupported.app_error", nil, "service="+service)
+ return nil, "", nil, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.unsupported.app_error", nil, "service="+service, http.StatusNotImplemented)
}
stateStr := ""
if b, err := b64.StdEncoding.DecodeString(state); err != nil {
- return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.invalid_state.app_error", nil, err.Error())
+ return nil, "", nil, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.invalid_state.app_error", nil, err.Error(), http.StatusBadRequest)
} else {
stateStr = string(b)
}
@@ -674,7 +674,7 @@ func AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, s
var ar *model.AccessResponse
var bodyBytes []byte
if resp, err := utils.HttpClient(true).Do(req); err != nil {
- return nil, "", stateProps, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.token_failed.app_error", nil, err.Error())
+ 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))
@@ -682,16 +682,16 @@ func AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, s
ar = model.AccessResponseFromJson(resp.Body)
defer CloseBody(resp)
if ar == nil {
- return nil, "", stateProps, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, "response_body="+string(bodyBytes))
+ return nil, "", stateProps, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, "response_body="+string(bodyBytes), http.StatusInternalServerError)
}
}
if strings.ToLower(ar.TokenType) != model.ACCESS_TOKEN_TYPE {
- return nil, "", stateProps, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_token.app_error", nil, "token_type="+ar.TokenType+", response_body="+string(bodyBytes))
+ return nil, "", stateProps, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_token.app_error", nil, "token_type="+ar.TokenType+", response_body="+string(bodyBytes), http.StatusInternalServerError)
}
if len(ar.AccessToken) == 0 {
- return nil, "", stateProps, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.missing.app_error", nil, "response_body="+string(bodyBytes))
+ return nil, "", stateProps, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.missing.app_error", nil, "response_body="+string(bodyBytes), http.StatusInternalServerError)
}
p = url.Values{}
@@ -703,8 +703,7 @@ func AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, s
req.Header.Set("Authorization", "Bearer "+ar.AccessToken)
if resp, err := utils.HttpClient(true).Do(req); err != nil {
- return nil, "", stateProps, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.service.app_error",
- map[string]interface{}{"Service": service}, err.Error())
+ return nil, "", stateProps, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.service.app_error", map[string]interface{}{"Service": service}, err.Error(), http.StatusInternalServerError)
} else {
return resp.Body, teamId, stateProps, nil
}