You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John <jo...@quivinco.com> on 2013/04/29 10:47:59 UTC

problem with jumpstart protecting pages code

I don't think the following code works, it doesn't when I run my version of it.

The loginPage has it's nextPageLink property set, but then the loginPageLink is returned by using the Login.class which presumably just redirects to a fresh login page without the nextPageLink set.

So the nextPageLink is null in the Login page so the nextPageLink cannot be used.

John

http://jumpstart.doublenegative.com.au/jumpstart/examples/infrastructure/protectingpages


            // Get the Login page, give it a link to the requested page, and redirect to Login

            IIntermediatePage loginPage = (IIntermediatePage) componentSource.getPage(Login.class);

            Link requestedPageLink = makeLinkToRequestedPage(requestedPageName, eventContext);
            loginPage.setNextPageLink(requestedPageLink);

            Link loginPageLink = pageRenderLinkSource.createPageRenderLink(Login.class);
            response.sendRedirect(loginPageLink);

            return false;

Re: problem with jumpstart protecting pages code

Posted by Geoff Callender <ge...@gmail.com>.
Yep, I, too, avoid session persistence like the plague. But in this case I
figure that it's fair enough because we're about to use the session anyway
when they log in (it creates a "Visit" and stores it with @SessionState).
We remove the link from Login afterwards with
discardPersistentFieldChanges() .


On 30 April 2013 08:43, John <jo...@quivinco.com> wrote:

> Bingo! You are right, @Persist was missing from my login page nextPageLink
> member. I'm not much a fan of putting data in session and probably ignored
> or junked that essential @Persist!
>
> thanks,
> John
>   ----- Original Message -----
>   From: Geoff Callender
>   To: Tapestry users
>   Sent: Monday, April 29, 2013 10:35 PM
>   Subject: Re: problem with jumpstart protecting pages code
>
>
>   Hi John,
>
>   It works because LoginPage persists the link in your session:
>
>      @Persist
>       private Link nextPageLink;
>
>   Have you really seen it fail? Try for yourself - try user 2 (login with
> admin, admin):
>
>
> http://jumpstart.doublenegative.com.au/jumpstart/theapp/security/userview/2
>
>   then log out, then try user 3:
>
>
> http://jumpstart.doublenegative.com.au/jumpstart/theapp/security/userview/3
>
>   then log out, then try role 1:
>
>
> http://jumpstart.doublenegative.com.au/jumpstart/theapp/security/roleview/1
>
>   Does it ever not work? If it needs fixing then I'd really like to know.
>
>   Geoff
>
>
>   On 29/04/2013, at 6:47 PM, John wrote:
>
>   > I don't think the following code works, it doesn't when I run my
> version of it.
>   >
>   > The loginPage has it's nextPageLink property set, but then the
> loginPageLink is returned by using the Login.class which presumably just
> redirects to a fresh login page without the nextPageLink set.
>   >
>   > So the nextPageLink is null in the Login page so the nextPageLink
> cannot be used.
>   >
>   > John
>   >
>   >
> http://jumpstart.doublenegative.com.au/jumpstart/examples/infrastructure/protectingpages
>   >
>   >
>   >            // Get the Login page, give it a link to the requested
> page, and redirect to Login
>   >
>   >            IIntermediatePage loginPage = (IIntermediatePage)
> componentSource.getPage(Login.class);
>   >
>   >            Link requestedPageLink =
> makeLinkToRequestedPage(requestedPageName, eventContext);
>   >            loginPage.setNextPageLink(requestedPageLink);
>   >
>   >            Link loginPageLink =
> pageRenderLinkSource.createPageRenderLink(Login.class);
>   >            response.sendRedirect(loginPageLink);
>   >
>   >            return false;
>
>

Re: problem with jumpstart protecting pages code

Posted by John <jo...@quivinco.com>.
Bingo! You are right, @Persist was missing from my login page nextPageLink member. I'm not much a fan of putting data in session and probably ignored or junked that essential @Persist!

thanks,
John
  ----- Original Message ----- 
  From: Geoff Callender 
  To: Tapestry users 
  Sent: Monday, April 29, 2013 10:35 PM
  Subject: Re: problem with jumpstart protecting pages code


  Hi John,

  It works because LoginPage persists the link in your session:

     @Persist
      private Link nextPageLink;

  Have you really seen it fail? Try for yourself - try user 2 (login with admin, admin):

  http://jumpstart.doublenegative.com.au/jumpstart/theapp/security/userview/2

  then log out, then try user 3:

  http://jumpstart.doublenegative.com.au/jumpstart/theapp/security/userview/3

  then log out, then try role 1:

  http://jumpstart.doublenegative.com.au/jumpstart/theapp/security/roleview/1

  Does it ever not work? If it needs fixing then I'd really like to know.

  Geoff


  On 29/04/2013, at 6:47 PM, John wrote:

  > I don't think the following code works, it doesn't when I run my version of it.
  > 
  > The loginPage has it's nextPageLink property set, but then the loginPageLink is returned by using the Login.class which presumably just redirects to a fresh login page without the nextPageLink set.
  > 
  > So the nextPageLink is null in the Login page so the nextPageLink cannot be used.
  > 
  > John
  > 
  > http://jumpstart.doublenegative.com.au/jumpstart/examples/infrastructure/protectingpages
  > 
  > 
  >            // Get the Login page, give it a link to the requested page, and redirect to Login
  > 
  >            IIntermediatePage loginPage = (IIntermediatePage) componentSource.getPage(Login.class);
  > 
  >            Link requestedPageLink = makeLinkToRequestedPage(requestedPageName, eventContext);
  >            loginPage.setNextPageLink(requestedPageLink);
  > 
  >            Link loginPageLink = pageRenderLinkSource.createPageRenderLink(Login.class);
  >            response.sendRedirect(loginPageLink);
  > 
  >            return false;


Re: problem with jumpstart protecting pages code

Posted by Geoff Callender <ge...@gmail.com>.
Hi John,

It works because LoginPage persists the link in your session:

   @Persist
    private Link nextPageLink;

Have you really seen it fail? Try for yourself - try user 2 (login with admin, admin):

	http://jumpstart.doublenegative.com.au/jumpstart/theapp/security/userview/2

then log out, then try user 3:

	http://jumpstart.doublenegative.com.au/jumpstart/theapp/security/userview/3

then log out, then try role 1:

	http://jumpstart.doublenegative.com.au/jumpstart/theapp/security/roleview/1

Does it ever not work? If it needs fixing then I'd really like to know.

Geoff


On 29/04/2013, at 6:47 PM, John wrote:

> I don't think the following code works, it doesn't when I run my version of it.
> 
> The loginPage has it's nextPageLink property set, but then the loginPageLink is returned by using the Login.class which presumably just redirects to a fresh login page without the nextPageLink set.
> 
> So the nextPageLink is null in the Login page so the nextPageLink cannot be used.
> 
> John
> 
> http://jumpstart.doublenegative.com.au/jumpstart/examples/infrastructure/protectingpages
> 
> 
>            // Get the Login page, give it a link to the requested page, and redirect to Login
> 
>            IIntermediatePage loginPage = (IIntermediatePage) componentSource.getPage(Login.class);
> 
>            Link requestedPageLink = makeLinkToRequestedPage(requestedPageName, eventContext);
>            loginPage.setNextPageLink(requestedPageLink);
> 
>            Link loginPageLink = pageRenderLinkSource.createPageRenderLink(Login.class);
>            response.sendRedirect(loginPageLink);
> 
>            return false;