diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index 3d70ca9a5067..be60a0c73ba2 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -847,6 +847,11 @@ func SignInOAuth(ctx *context.Context) { return } + redirectTo := ctx.FormString("redirect_to") + if len(redirectTo) > 0 { + middleware.SetRedirectToCookie(ctx.Resp, redirectTo) + } + // try to do a direct callback flow, so we don't authenticate the user again but use the valid accesstoken to get the user user, gothUser, err := oAuth2UserLoginCallback(authSource, ctx.Req, ctx.Resp) if err == nil && user != nil {