[Catalyst] Global behaviour modification

Tomas Doran bobtfish at bobtfish.net
Sat Mar 27 21:46:43 GMT 2010

On 27 Mar 2010, at 13:01, J. Shirley wrote:
> The approach I take, and recommend, is to use Chained for this (though
> on an existing application it may be too late).
> You can setup chains for auth required that redirects as desired, then
> anything that doesn't need authentication can either tie to a
> mid-point action that doesn't (for logging?) or simply chain to ("/").
> CatalystX::SimpleLogin simply chains to "/" (See
> http://cpansearch.perl.org/src/BOBTFISH/CatalystX-SimpleLogin-0.09/lib/CatalystX/SimpleLogin/Controller/Login.pm)
> to not get caught up on any midpoint interceptions, but this is
> overridable via configuration.

CatalystX::SimpleLogin::Controller::Login provides chained start  
points for you to chain everything off of.

These are:


In this case, where you want to add additional logic to the /login/ 
required case, you want to make a MyApp::Controller::Login which  
subclasses CatalystX::SimpleLogin::Controller::Login, remove  
CatalystX::SimpleLogin from your plugin list (as this merely serves to  
inject the default controller you have overridden), and add a method  
modifier to the 'required' method in your code to implement your 'if  
condition, redirect user' logic.

This approach, as J noted, is of course predicated on the fact that  
you have based the entire authenticated portion of your application  
off of the chain base provided. :_)


P.S. I really haven't had enough tuits to give CX::SimpleLogin the  
love (or docs) it deserves since I talked about it at LPW last year.  
If anyone fancies stepping up to the plate and taking over  
maintainership (or generally just helping add docs to what is already  
there), then you'd be extremely welcome..

More information about the Catalyst mailing list