[Catalyst] What's the best way to exclude static requests from
needing user to log in?
Nickolay Platonov
nickolay8 at gmail.com
Sat Apr 25 10:00:19 GMT 2009
Oh, I didn't knew, I can use custom attributes, cool..
On Mon, Apr 20, 2009 at 5:13 PM, Matt S Trout <dbix-class at trout.me.uk>wrote:
> On Sun, Apr 19, 2009 at 05:53:42PM +0400, Nickolay Platonov wrote:
> > and I'm using this to implicitly specify which actions in controllers
> > require authorization:
> >
> > #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> > #Controller
> >
> > sub update :Local :ActionClass('+Travel::Action::AuthorizationRequired')
> {
> > my ( $self, $c ) =3D @_;
> >
> > my $token =3D $c->req->params->{'token'};
> > ..........
> > }
> >
> > #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> > #AuthorizationRequired Action
> >
> > sub execute {
> > my $self =3D shift;
> > my ( $controller, $c ) =3D @_;
> >
> > if ( !$c->user_exists() ) {
> >
> > $c->stash->{template} =3D "auth_required.tt2";
> >
> > $c->detach('View::TT');
> > }
> >
> > $self->NEXT::execute( @_ );
> > };
>
> That's a lot of complexity compared to:
>
> sub update :Local :AuthorizationRequired {
> ...
> }
>
> sub auto :Private { # in Root.pm (or use a root chain part to do the same)
> my ($self, $c) =3D @_;
> if ($c->action->attributes->{AuthorizationRequired} && $c->user_exists) {
> $c->forward('auth_required');
> return 0;
> }
> }
>
> sub auth_required :Private {
> my ($self, $c) =3D @_;
> $c->stash(template =3D> 'auth_required.tt2');
> }
>
> --
> Matt S Trout Need help with your Catalyst or DBIx::Class
> project?
> Technical Director
> http://www.shadowcat.co.uk/catalyst/
> Shadowcat Systems Ltd. Want a managed development or deployment platfor=
m?
> http://chainsawblues.vox.com/
> http://www.shadowcat.co.uk/servers/
>
> _______________________________________________
> List: Catalyst at 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/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090425/96ba5=
990/attachment.htm
More information about the Catalyst
mailing list