consider exiting page immediately on redirect in init
you can use page/template init block for this
page root {
init{
if(!loggedIn()){return login();}
}
}Yoshi van den Akker
4:15 PM
Apparently this doesn’t guarantee the code on the main page isn’t run. If I redirect an unauthenticated user to login in an init block, but try to access some principal field later in the page (e.g. if (principal.role == Admin)), I get a nullpointer. Is that the intended behaviour?Danny Groenewegen - EWI
Submitted by Danny Groenewegen on 8 April 2022 at 19:24
7:23 PM
it’s unfortunate but correct according to the current semantics, it could be a nice idea to short circuit when a redirect is triggered in init and skip the rest, but this currently is not implemented that way
Log in to post comments