[Catalyst] Root.pm $c->detach() does not detach?
Brian Kirkbride
brian.kirkbride at deeperbydesign.com
Tue Apr 3 17:50:14 GMT 2007
Luis Azevedo wrote:
> Hi All,
>
> In Root.pm, "auto" action I am trying to break the execution of chain of
> Actions.
>
> To be more exact, whenever I detect I loose connection to a socket or cookie
> session, I want to redirect the user to a login action, not rendering the
> action the user is calling.
>
> I know I can make a simple $c->res->redirect() but the problem is I need to
> show a message in the login page telling the reason for the "logout". Usually
> I am passing messages trough Stash. Redirecting to the Login page needs to
> pass message somehow (through GET or POST, therefore not so beautiful s).
>
> I have tried to detach the /login action, in "auto" action from Root.pm
> controller, but it is not working and I don't know why. See the actions
> chain:
> | /auto
> | -> /login/index
> | /about/index
> | /end
>
> The user called the /about action.
>
> Can I break the chain somehow in Root.pm, "auto" action?
>
> Thanks in advance,
>
I think what you want is something like
if (!$logged_in) {
$c->action(undef);
$c->detach('/login');
}
Setting the action to undef in an auto sub will prevent the normal dispatch of
the request.
Best,
Brian
More information about the Catalyst
mailing list