summaryrefslogtreecommitdiffstats
path: root/utils/api.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 /utils/api.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 'utils/api.go')
-rw-r--r--utils/api.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/utils/api.go b/utils/api.go
index 228808f3c..55f84ef92 100644
--- a/utils/api.go
+++ b/utils/api.go
@@ -5,7 +5,10 @@ package utils
import (
"net/http"
+ "net/url"
"strings"
+
+ "github.com/mattermost/platform/model"
)
type OriginCheckerProc func(*http.Request) bool
@@ -22,3 +25,28 @@ func GetOriginChecker(r *http.Request) OriginCheckerProc {
return nil
}
+
+func RenderWebError(err *model.AppError, w http.ResponseWriter, r *http.Request) {
+ T, _ := GetTranslationsAndLocale(w, r)
+
+ title := T("api.templates.error.title", map[string]interface{}{"SiteName": 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)
+}