Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Use CatalystX::SimpleLogin Globally

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


jatzger at hotmail

Feb 6, 2010, 1:56 PM

Post #1 of 4 (1112 views)
Permalink
Use CatalystX::SimpleLogin Globally

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.
Thank you.Jatzger
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/201469227/direct/01/


rafl at debian

Feb 6, 2010, 2:22 PM

Post #2 of 4 (1053 views)
Permalink
Re: Use CatalystX::SimpleLogin Globally [In reply to]

Catalyst::Controller::ActionRole documents how to apply roles to all
actions of a controller, without specifying the roles for each action
individually.


--
BOFH excuse #302:
microelectronic Riemannian curved-space fault in write-only file system
Attachments: signature.asc (0.18 KB)


catalyst4 at augensalat

Feb 6, 2010, 2:22 PM

Post #3 of 4 (1049 views)
Permalink
Re: Use CatalystX::SimpleLogin Globally [In reply to]

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/


catalyst4 at augensalat

Feb 6, 2010, 2:32 PM

Post #4 of 4 (1042 views)
Permalink
Re: Use CatalystX::SimpleLogin Globally [In reply to]

Bernhard Graf schrieb:

> # everything under /login needs login
> sub root : Chained(/) PathPart(admin) CaptureArgs(0) Does(NeedsLogin)
> {...}

correction:
# everything under /admin needs login

_______________________________________________
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/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.