Skip to content

Commit

Permalink
Prevent redirect back to /user/events (#12462)
Browse files Browse the repository at this point in the history
This PR prevents 2 further ways of causing the redirect cookie to be set
to redirect back to /user/events

Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath authored Aug 8, 2020
1 parent 78d17b4 commit 02e990a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions modules/context/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ func Toggle(options *ToggleOptions) macaron.Handler {
})
return
}

ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL)
if ctx.Req.URL.Path != "/user/events" {
ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL)
}
ctx.Redirect(setting.AppSubURL + "/user/login")
return
} else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm {
Expand Down Expand Up @@ -120,7 +121,9 @@ func Toggle(options *ToggleOptions) macaron.Handler {
// Redirect to log in page if auto-signin info is provided and has not signed in.
if !options.SignOutRequired && !ctx.IsSigned && !auth.IsAPIPath(ctx.Req.URL.Path) &&
len(ctx.GetCookie(setting.CookieUserName)) > 0 {
ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL)
if ctx.Req.URL.Path != "/user/events" {
ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL)
}
ctx.Redirect(setting.AppSubURL + "/user/login")
return
}
Expand Down

0 comments on commit 02e990a

Please sign in to comment.