diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-08-01 16:55:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-01 16:55:18 +0200 |
commit | d81a61398d01d839e70e2345da787e7ef89c0832 (patch) | |
tree | a0702c7874ae31b487bb0b87dcce613edc1e53b9 /api4/oauth.go | |
parent | 1f168263a2ff73ddee1193cccdeea533f6d501fe (diff) | |
download | chat-d81a61398d01d839e70e2345da787e7ef89c0832.tar.gz chat-d81a61398d01d839e70e2345da787e7ef89c0832.tar.bz2 chat-d81a61398d01d839e70e2345da787e7ef89c0832.zip |
Migrate all the api4 to handle errors in idiomatic way (#9143)
Diffstat (limited to 'api4/oauth.go')
-rw-r--r-- | api4/oauth.go | 25 |
1 files changed, 14 insertions, 11 deletions
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) } |