summaryrefslogtreecommitdiffstats
path: root/api4/oauth.go
diff options
context:
space:
mode:
Diffstat (limited to 'api4/oauth.go')
-rw-r--r--api4/oauth.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/api4/oauth.go b/api4/oauth.go
index 402651b92..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
}
@@ -400,15 +402,19 @@ 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
+ 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
}
@@ -455,7 +461,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 +481,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 +506,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 {