From 15ad24d160cb4604d0605ebbfa53d11a57820706 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Thu, 6 Jul 2017 17:28:38 -0400 Subject: Minor fix --- api4/oauth.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'api4/oauth.go') diff --git a/api4/oauth.go b/api4/oauth.go index 402651b92..d00b4a666 100644 --- a/api4/oauth.go +++ b/api4/oauth.go @@ -400,7 +400,7 @@ func completeOAuth(c *Context, w http.ResponseWriter, r *http.Request) { uri := c.GetSiteURLHeader() + "/signup/" + service + "/complete" - body, teamId, props, err := app.AuthorizeOAuthUser(service, code, state, uri) + body, teamId, props, err := app.AuthorizeOAuthUser(w, r, service, code, state, uri) if err != nil { c.Err = err return @@ -455,7 +455,7 @@ func loginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) { return } - if authUrl, err := app.GetOAuthLoginEndpoint(c.Params.Service, teamId, model.OAUTH_ACTION_LOGIN, redirectTo, loginHint); err != nil { + if authUrl, err := app.GetOAuthLoginEndpoint(w, r, c.Params.Service, teamId, model.OAUTH_ACTION_LOGIN, redirectTo, loginHint); err != nil { c.Err = err return } else { @@ -475,7 +475,7 @@ func mobileLoginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) { return } - if authUrl, err := app.GetOAuthLoginEndpoint(c.Params.Service, teamId, model.OAUTH_ACTION_MOBILE, "", ""); err != nil { + if authUrl, err := app.GetOAuthLoginEndpoint(w, r, c.Params.Service, teamId, model.OAUTH_ACTION_MOBILE, "", ""); err != nil { c.Err = err return } else { @@ -500,7 +500,7 @@ func signupWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) { return } - if authUrl, err := app.GetOAuthSignupEndpoint(c.Params.Service, teamId); err != nil { + if authUrl, err := app.GetOAuthSignupEndpoint(w, r, c.Params.Service, teamId); err != nil { c.Err = err return } else { -- cgit v1.2.3-1-g7c22 From f3acd34128a3553e3a8f7e2da85be470c73e326b Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 10 Jul 2017 14:52:59 -0400 Subject: Redirect OAuth SSO errors to error page (#6898) --- api4/oauth.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'api4/oauth.go') 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 } -- cgit v1.2.3-1-g7c22