From d81a61398d01d839e70e2345da787e7ef89c0832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Wed, 1 Aug 2018 16:55:18 +0200 Subject: Migrate all the api4 to handle errors in idiomatic way (#9143) --- api4/oauth.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'api4/oauth.go') diff --git a/api4/oauth.go b/api4/oauth.go index d747e3422..961b0fecd 100644 --- a/api4/oauth.go +++ b/api4/oauth.go @@ -520,9 +520,9 @@ func completeOAuth(c *Context, w http.ResponseWriter, r *http.Request) { if action == model.OAUTH_ACTION_MOBILE { ReturnStatusOK(w) return - } else { - http.Redirect(w, r, redirectUrl, http.StatusTemporaryRedirect) } + + http.Redirect(w, r, redirectUrl, http.StatusTemporaryRedirect) } func loginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) { @@ -540,12 +540,13 @@ func loginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) { return } - if authUrl, err := c.App.GetOAuthLoginEndpoint(w, r, c.Params.Service, teamId, model.OAUTH_ACTION_LOGIN, redirectTo, loginHint); err != nil { + authUrl, err := c.App.GetOAuthLoginEndpoint(w, r, c.Params.Service, teamId, model.OAUTH_ACTION_LOGIN, redirectTo, loginHint) + if err != nil { c.Err = err return - } else { - http.Redirect(w, r, authUrl, http.StatusFound) } + + http.Redirect(w, r, authUrl, http.StatusFound) } func mobileLoginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) { @@ -560,12 +561,13 @@ func mobileLoginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) { return } - if authUrl, err := c.App.GetOAuthLoginEndpoint(w, r, c.Params.Service, teamId, model.OAUTH_ACTION_MOBILE, "", ""); err != nil { + authUrl, err := c.App.GetOAuthLoginEndpoint(w, r, c.Params.Service, teamId, model.OAUTH_ACTION_MOBILE, "", "") + if err != nil { c.Err = err return - } else { - http.Redirect(w, r, authUrl, http.StatusFound) } + + http.Redirect(w, r, authUrl, http.StatusFound) } func signupWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) { @@ -587,10 +589,11 @@ func signupWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) { return } - if authUrl, err := c.App.GetOAuthSignupEndpoint(w, r, c.Params.Service, teamId); err != nil { + authUrl, err := c.App.GetOAuthSignupEndpoint(w, r, c.Params.Service, teamId) + if err != nil { c.Err = err return - } else { - http.Redirect(w, r, authUrl, http.StatusFound) } + + http.Redirect(w, r, authUrl, http.StatusFound) } -- cgit v1.2.3-1-g7c22