]> source.dussan.org Git - gitea.git/commitdiff
#3448 redirect if any after sign in
authorUnknwon <u@gogs.io>
Sat, 27 Aug 2016 22:07:02 +0000 (15:07 -0700)
committerUnknwon <u@gogs.io>
Sat, 27 Aug 2016 22:07:02 +0000 (15:07 -0700)
routers/user/auth.go

index 40687fca6fa0357db11d506269cdbadfb7db74b1..031ac026bd370a940b9ab8a585c7701ca74c018e 100644 (file)
@@ -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 {