浏览代码

#3448 redirect if any after sign in

Unknwon 8 年之前
父节点
当前提交
f0b5c3b90a
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      routers/user/auth.go

+ 8 - 1
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 {