[Catalyst] tutorial problem : adding an auto action

Daniel McBrearty danielmcbrearty at gmail.com
Sun Mar 5 16:54:48 CET 2006


Hi

gradually getting to get to know catalyst by working through the tutorial
...

I am trying to add an "auto" action which will cause users to be
authenticated using an "auto" action "as suggested in the Exercise section
of the tutorial" ...

My first attempt was this:

sub auto : Private {
    my ( $self, $c ) = @_;
    if ( !$c->user ) {
    $c->res->redirect( '/users/login' ); # require login
    return 0; # abort request and go immediately to end()
    }
    return 1; # success; carry on to next action
}

which caused a template not found error, because the end method looks like
this:

sub end : Private {
   my ($self, $c) = @_;
   $c->forward('TestApp::View::TToolkit') unless $c->res->body();
 }

After some experimenting and reading docs I worked out that if the auto
method returns 0, it then causes the end method to fail.

As a workaround, I added this line:

$c->res->body("redirecting to login ...");

to the auto method - this stops the error (by preventing the forwarding of
the action to TT - it's a bit of a bodge I know, but I'm just finding me
feet here ... ) - but now I get :

"redirection limit for this url exceeded ... This may be caused by cookies
that are blocked." in the (Mozilla) browser. (even after clearing cookies).

I feel like I'm missing something here - can anyone explain:

1. how to make the TT forwarding work without triggering an error if the
body of the page is empty? This should be possible, right?
2. why I get this browser error about redirection limit, and how to fix it?

thanks!

Daniel


--
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20060305/7e037b00/attachment.htm 


More information about the Catalyst mailing list