diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-22 17:59:22 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-22 17:59:22 -0400 |
commit | 7356153ba3c19ff49f3ecfa28bac0b8bb38eccb9 (patch) | |
tree | d6cb7f9a7317eaddc981708e2a104020370e66d7 /routers/user/user.go | |
parent | cb52f6d07d62925a31185fedf591d0241ee2bf63 (diff) | |
download | gitea-7356153ba3c19ff49f3ecfa28bac0b8bb38eccb9.tar.gz gitea-7356153ba3c19ff49f3ecfa28bac0b8bb38eccb9.zip |
Batch updates
Diffstat (limited to 'routers/user/user.go')
-rw-r--r-- | routers/user/user.go | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/routers/user/user.go b/routers/user/user.go index 56bc5f8e37..c34b529ec3 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -6,6 +6,7 @@ package user import ( "fmt" + "net/url" "strings" "github.com/codegangsta/martini" @@ -109,7 +110,13 @@ func SignIn(ctx *middleware.Context, form auth.LogInForm) { isSucceed = true ctx.Session.Set("userId", user.Id) ctx.Session.Set("userName", user.Name) - ctx.Redirect("/") + redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")) + if len(redirectTo) > 0 { + ctx.SetCookie("redirect_to", "", -1) + ctx.Redirect(redirectTo) + } else { + ctx.Redirect("/") + } return } @@ -139,12 +146,20 @@ func SignIn(ctx *middleware.Context, form auth.LogInForm) { ctx.Session.Set("userId", user.Id) ctx.Session.Set("userName", user.Name) - ctx.Redirect("/") + redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")) + if len(redirectTo) > 0 { + ctx.SetCookie("redirect_to", "", -1) + ctx.Redirect(redirectTo) + } else { + ctx.Redirect("/") + } } func SignOut(ctx *middleware.Context) { ctx.Session.Delete("userId") ctx.Session.Delete("userName") + ctx.SetCookie(base.CookieUserName, "", -1) + ctx.SetCookie(base.CookieRememberName, "", -1) ctx.Redirect("/") } @@ -314,7 +329,7 @@ func Activate(ctx *middleware.Context) { ctx.Session.Set("userId", user.Id) ctx.Session.Set("userName", user.Name) - ctx.Redirect("/", 302) + ctx.Redirect("/") return } |