[Catalyst] Global behaviour modification

Stuart Watt swatt at infobal.com
Sat Mar 27 15:29:13 GMT 2010


We have a "maintenance mode" in our app which is kind of similar. We do this before calling the authenticate method, and our entire app is covered by authentication, so it isn't quite the same. But this does the conditional global redirect. 

I guess you could check the action more imaginatively - I do this just to avoid looping/recursion. 

All the best
Stuart


sub begin : Private {
    my ( $self, $c ) = @_;
    ...
    if ($c->action()->name() ne 'maintenance') {
        my $maintenance = $c->config()->{maintenance} || 0;
        if ($maintenance == 1) {
            $c->go('maintenance');
        }
    }
    ...
}


On 2010-03-27, at 5:25 AM, Ovid wrote:

> --- On Sat, 27/3/10, Ovid <publiustemp-catalyst at yahoo.com> wrote:
> 
>> From: Ovid <publiustemp-catalyst at yahoo.com>
> 
>> I'm working on an app where users must authenticate (via
>> CatalystX::SimpleLogin and a custom ActionRole).  At
>> times, users may engage in activity which temporarily makes
>> it impossible to take any other action. Hypothetical
>> example: users kick off a job which takes 5 minutes to run,
>> so we restrict their ability to do *anything* else for that
>> 5 minutes. Thus, it would be nice if I could globally
>> redirect any authenticated user to something like
>> /user/waiting/ or something like that.
> 
> Er, actually that would be "disallow any actions requiring authentication". Some portions of the (FAQs, for example) don't require authentication. Thus, if "before execute" was the way to go, I'd need to know whether or not the user is taking an action requiring authentication.
> 
> Cheers,
> Ovid
> --
> Buy the book         - http://www.oreilly.com/catalog/perlhks/
> Tech blog            - http://blogs.perl.org/users/ovid/
> Twitter              - http://twitter.com/OvidPerl
> Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100327/23d68708/attachment.htm


More information about the Catalyst mailing list