
catalyst4 at augensalat
Feb 6, 2010, 2:22 PM
Post #3 of 4
(1049 views)
Permalink
|
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 [at] lists Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst [at] lists/ Dev site: http://dev.catalyst.perl.org/
|