diff options
author | Unknwon <u@gogs.io> | 2016-08-27 15:07:02 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-27 15:07:02 -0700 |
commit | f0b5c3b90a9ca4ef7c4759d49e91b3da80ff9c72 (patch) | |
tree | 55cdf9b4d89950c64ae3b00fa67926f9c5929d5d | |
parent | c30b856d147dd895507c8f2334a11ed4baab6c18 (diff) |
#3448 redirect if any after sign in
-rw-r--r-- | routers/user/auth.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/routers/user/auth.go b/routers/user/auth.go index 40687fca..031ac026 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -76,8 +76,15 @@ func SignIn(ctx *context.Context) { return } + redirectTo := ctx.Query("redirect_to") + if len(redirectTo) > 0 { + ctx.SetCookie("redirect_to", redirectTo, 0, setting.AppSubUrl) + } else { + redirectTo, _ = url.QueryUnescape(ctx.GetCookie("redirect_to")) + } + if isSucceed { - if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 { + if len(redirectTo) > 0 { ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl) ctx.Redirect(redirectTo) } else { |