diff --git a/appview/oauth/accounts.go b/appview/oauth/accounts.go index 87a963ac..98cf5121 100644 --- a/appview/oauth/accounts.go +++ b/appview/oauth/accounts.go @@ -126,10 +126,6 @@ func (o *OAuth) GetMultiAccountUser(r *http.Request) *MultiAccountUser { } } -type AuthReturnInfo struct { - ReturnURL string -} - func (o *OAuth) SetAuthReturn(w http.ResponseWriter, r *http.Request, returnURL string) error { session, err := o.SessStore.Get(r, AuthReturnName) if err != nil { @@ -145,17 +141,15 @@ func (o *OAuth) SetAuthReturn(w http.ResponseWriter, r *http.Request, returnURL return session.Save(r, w) } -func (o *OAuth) GetAuthReturn(r *http.Request) *AuthReturnInfo { +func (o *OAuth) GetAuthReturn(r *http.Request) string { session, err := o.SessStore.Get(r, AuthReturnName) if err != nil || session.IsNew { - return &AuthReturnInfo{} + return "" } returnURL, _ := session.Values[AuthReturnURL].(string) - return &AuthReturnInfo{ - ReturnURL: returnURL, - } + return returnURL } func (o *OAuth) ClearAuthReturn(w http.ResponseWriter, r *http.Request) error { diff --git a/appview/oauth/handler.go b/appview/oauth/handler.go index 8601ade9..4f6f8aaa 100644 --- a/appview/oauth/handler.go +++ b/appview/oauth/handler.go @@ -64,7 +64,7 @@ func (o *OAuth) callback(w http.ResponseWriter, r *http.Request) { ctx := r.Context() l := o.Logger.With("query", r.URL.Query()) - authReturn := o.GetAuthReturn(r) + redirectURL := o.GetAuthReturn(r) _ = o.ClearAuthReturn(w, r) sessData, err := o.ClientApp.ProcessCallback(ctx, r.URL.Query()) @@ -108,9 +108,8 @@ func (o *OAuth) callback(w http.ResponseWriter, r *http.Request) { } } - redirectURL := "/" - if authReturn.ReturnURL != "" { - redirectURL = authReturn.ReturnURL + if redirectURL == "" { + redirectURL = "/" } if o.isAccountDeactivated(sessData) {