[Catalyst] What's the best way to exclude static requests from
needing user to log in?
Nickolay Platonov
nickolay8 at gmail.com
Sun Apr 19 13:53:42 GMT 2009
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( @_ );
};
On Sun, Apr 19, 2009 at 2:18 PM, Matt S Trout <dbix-class at trout.me.uk>wrote:
> On Sun, Apr 19, 2009 at 10:06:51AM +1000, kakimoto at tpg.com.au wrote:
> >
> > hi, all
> >
> > what's the best way to exclude static requests from needing the user
> > to log in?
> > Some parts of my site are open to general public. For example, the
> > 'contact us', 'services portfolio' and so forth pages.
> >
> > At the moment, I have put in codes in my MyApp::Controller::Root->auto
> > and it seems to want every request to be logged on.
>
> Two options:
>
> (1) (preferred) use Chained and have two root chain points, one that
> requires
> login and one that doesn't
>
> (2) sub static_serving_thing :NoLogin and check for
> $c->action->attributes->{NoLogin} in your root auto
>
> I'd suggest avoiding the ACL plugin; the implementation's a complete hack
> and Chained effectively obsoletes it anyway.
>
> --
> 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/20090419/406e7=
fd3/attachment.htm
More information about the Catalyst
mailing list