Bernhard Graf
Sat, 06 Feb 2010 14:26:09 -0800
John Atzger schrieb:
> I use CatalystX::SimpleLogin but I have to use "Does('NeedsLogin')" for
> every method. For controllers which require a login for anything, what I
> want is this:
>
> package Some::Controller::Stuff;
> use Moose;
> BEGIN { extend 'My::Controller::LoginRequired' }
>
> I tried something like this:
>
> package My::Controller::LoginRequired;
>
> use Moose;
> use namespace::autoclean;
>
> BEGIN { extends 'Catalyst::Controller::ActionRole' }
>
> sub auto :Private :Does('NeedsLogin') {}
>
> But that doesn't work. People can access actions in
> Some::Controller::Suff without logging in. I think I just don't
> understand Catalyst well enough to know what to do here.
Read this, maybe it helps http://search.cpan.org/perldoc?Catalyst::Controller::ActionRole Or look at the source code of http://search.cpan.org/src/BOBTFISH/CatalystX-SimpleLogin-0.08/lib/Catalyst/ActionRole/NeedsLogin.pm you could virtually take this code and put it into your auto action. Or if you use chained actions, you could add the Does(NeedsLogin) attribute to any action chain link: package My::Controller::LoginRequired; # everything under /login needs login sub root : Chained(/) PathPart(admin) CaptureArgs(0) Does(NeedsLogin) {...} package Some::Controller::Stuff; sub foo : Chained(/admin) PathPart Args(0) {...} Good luck Bernhard _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/