SiteMap redirects not consistently redirecting
It looks like Loc is being too eager about caching its params.
The following code should cause all requests to redirect to the login screen until the user logs in. Instead it redirects only the first page accessed. Any other URL does not redirect. That first page is stuck redirecting, even after the user has logged in. And it only prints "Redirecting to login" on the very first login.
If I use setSiteMapFunc instead of setSiteMap, and set my run.mode to debug, then I get the behavior I expect.
Please see this thread on the mailing list.
The following code should cause all requests to redirect to the login screen until the user logs in. Instead it redirects only the first page accessed. Any other URL does not redirect. That first page is stuck redirecting, even after the user has logged in. And it only prints "Redirecting to login" on the very first login.
def isLoggedIn = User.loggedIn_?
LiftRules.setSiteMap(new SiteMap(List({
case Full(Req(path, _, _)) if !isLoggedIn && path != List("user_mgt", "login") =>
logger.debug("Redirecting to login")
Loc.EarlyResponse(() => Full(RedirectResponse("/user_mgt/login")))
}), entries:_*))
If I use setSiteMapFunc instead of setSiteMap, and set my run.mode to debug, then I get the behavior I expect.
Please see this thread on the mailing list.
Leave a comment