From 217430e56b35e69436d7b59127c575aaf21623af Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 19 Aug 2020 15:40:07 -0400 Subject: [PATCH] Redirect user to /me/settings on cancelled OAuth flow --- oauth.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/oauth.go b/oauth.go index 620ffaf..e3f65ef 100644 --- a/oauth.go +++ b/oauth.go @@ -326,6 +326,12 @@ func (h oauthHandler) viewOauthCallback(app *App, w http.ResponseWriter, r *http tokenResponse, err := h.oauthClient.exchangeOauthCode(ctx, code) if err != nil { log.Error("Unable to exchangeOauthCode: %s", err) + // TODO: show user friendly message if needed + // TODO: show NO message for cases like user pressing "Cancel" on authorize step + addSessionFlash(app, w, r, err.Error(), nil) + if attachUserID > 0 { + return impart.HTTPError{http.StatusFound, "/me/settings"} + } return impart.HTTPError{http.StatusInternalServerError, err.Error()} }