summaryrefslogtreecommitdiffstats
path: root/api/context.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-04-20 09:55:02 -0400
committerGitHub <noreply@github.com>2017-04-20 09:55:02 -0400
commitbe9624e2adce7c95039e62fc4ee22538d7fa2d2f (patch)
tree318179b4d3a4cb5114f887797a5a4c836e5255d7 /api/context.go
parent1a0f8d1b3c7451eac43bfdc5971de060caabf441 (diff)
downloadchat-be9624e2adce7c95039e62fc4ee22538d7fa2d2f.tar.gz
chat-be9624e2adce7c95039e62fc4ee22538d7fa2d2f.tar.bz2
chat-be9624e2adce7c95039e62fc4ee22538d7fa2d2f.zip
Implement v4 endpoints for OAuth (#6040)
* Implement POST /oauth/apps endpoint for APIv4 * Implement GET /oauth/apps endpoint for APIv4 * Implement GET /oauth/apps/{app_id} and /oauth/apps/{app_id}/info endpoints for APIv4 * Refactor API version independent oauth endpoints * Implement DELETE /oauth/apps/{app_id} endpoint for APIv4 * Implement /oauth/apps/{app_id}/regen_secret endpoint for APIv4 * Implement GET /user/{user_id}/oauth/apps/authorized endpoint for APIv4 * Implement POST /oauth/deauthorize endpoint
Diffstat (limited to 'api/context.go')
-rw-r--r--api/context.go29
1 files changed, 2 insertions, 27 deletions
diff --git a/api/context.go b/api/context.go
index 21bbb1e37..282b45c86 100644
--- a/api/context.go
+++ b/api/context.go
@@ -242,7 +242,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if c.Err.StatusCode == http.StatusUnauthorized {
http.Redirect(w, r, c.GetTeamURL()+"/?redirect="+url.QueryEscape(r.URL.Path), http.StatusTemporaryRedirect)
} else {
- RenderWebError(c.Err, w, r)
+ utils.RenderWebError(c.Err, w, r)
}
}
@@ -421,31 +421,6 @@ func IsApiCall(r *http.Request) bool {
return strings.Index(r.URL.Path, "/api/") == 0
}
-func RenderWebError(err *model.AppError, w http.ResponseWriter, r *http.Request) {
- T, _ := utils.GetTranslationsAndLocale(w, r)
-
- title := T("api.templates.error.title", map[string]interface{}{"SiteName": utils.ClientCfg["SiteName"]})
- message := err.Message
- details := err.DetailedError
- link := "/"
- linkMessage := T("api.templates.error.link")
-
- status := http.StatusTemporaryRedirect
- if err.StatusCode != http.StatusInternalServerError {
- status = err.StatusCode
- }
-
- http.Redirect(
- w,
- r,
- "/error?title="+url.QueryEscape(title)+
- "&message="+url.QueryEscape(message)+
- "&details="+url.QueryEscape(details)+
- "&link="+url.QueryEscape(link)+
- "&linkmessage="+url.QueryEscape(linkMessage),
- status)
-}
-
func Handle404(w http.ResponseWriter, r *http.Request) {
err := model.NewLocAppError("Handle404", "api.context.404.app_error", nil, "")
err.Translate(utils.T)
@@ -458,7 +433,7 @@ func Handle404(w http.ResponseWriter, r *http.Request) {
err.DetailedError = "There doesn't appear to be an api call for the url='" + r.URL.Path + "'. Typo? are you missing a team_id or user_id as part of the url?"
w.Write([]byte(err.ToJson()))
} else {
- RenderWebError(err, w, r)
+ utils.RenderWebError(err, w, r)
}
}