summaryrefslogtreecommitdiffstats
path: root/api4/oauth.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-07-10 14:52:59 -0400
committerSaturnino Abril <saturnino.abril@gmail.com>2017-07-11 02:52:59 +0800
commitf3acd34128a3553e3a8f7e2da85be470c73e326b (patch)
treeb4bed107cb4b2396a85e8f30b19c26dc2d895023 /api4/oauth.go
parent046dbc5e81e9bed0c47dbe84dfbd85df1e0f341a (diff)
downloadchat-f3acd34128a3553e3a8f7e2da85be470c73e326b.tar.gz
chat-f3acd34128a3553e3a8f7e2da85be470c73e326b.tar.bz2
chat-f3acd34128a3553e3a8f7e2da85be470c73e326b.zip
Redirect OAuth SSO errors to error page (#6898)
Diffstat (limited to 'api4/oauth.go')
-rw-r--r--api4/oauth.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/api4/oauth.go b/api4/oauth.go
index d00b4a666..05a38d206 100644
--- a/api4/oauth.go
+++ b/api4/oauth.go
@@ -392,7 +392,9 @@ func completeOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
code := r.URL.Query().Get("code")
if len(code) == 0 {
- c.Err = model.NewAppError("completeOAuth", "api.oauth.complete_oauth.missing_code.app_error", map[string]interface{}{"service": strings.Title(service)}, "URL: "+r.URL.String(), http.StatusBadRequest)
+ err := model.NewAppError("completeOAuth", "api.oauth.complete_oauth.missing_code.app_error", map[string]interface{}{"service": strings.Title(service)}, "URL: "+r.URL.String(), http.StatusBadRequest)
+ err.Translate(c.T)
+ http.Redirect(w, r, c.GetSiteURLHeader()+"/error?message="+err.Message, http.StatusTemporaryRedirect)
return
}
@@ -402,13 +404,17 @@ func completeOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
body, teamId, props, err := app.AuthorizeOAuthUser(w, r, service, code, state, uri)
if err != nil {
- c.Err = err
+ err.Translate(c.T)
+ l4g.Error(err.Error())
+ http.Redirect(w, r, c.GetSiteURLHeader()+"/error?message="+err.Message, http.StatusTemporaryRedirect)
return
}
user, err := app.CompleteOAuth(service, body, teamId, props)
if err != nil {
- c.Err = err
+ err.Translate(c.T)
+ l4g.Error(err.Error())
+ http.Redirect(w, r, c.GetSiteURLHeader()+"/error?message="+err.Message, http.StatusTemporaryRedirect)
return
}