[Catalyst] tutorial - adding "auth" function
Matt S Trout
dbix-class at trout.me.uk
Thu Jun 8 16:58:35 CEST 2006
Sarah Berry wrote:
> Thanks to everyone! It finally works, and here is the code:
>
> sub auto : Private {
> my ( $self, $c) = @_;
> #if ($c->request->path =~ m(users/login)) {
> if ($c->action->reverse eq 'users/login') {
> return 1;
> }
> if ( !$c->user_exists) { # Catalyst::Plugin::Authentication
> $c->res->redirect( '/users/login' ); # require login
> $c->res->body("Redirecting to login ... ");
> return 0; # abort request and go immediately to end()
> }
> return 1; # success; carry on to next action
> }
>
> sub end : Private {
> my ($self, $c) = @_;
> $c->forward('tutorial::View::TToolkit') unless $c->res->body();
> }
>
> I used Matt's suggestion so that, as Jürgen pointed out, someone
> couldn't access a page like http://server/users/delete/all /users/login .
>
> Thank you for the link to the new tutorial docs. I will definitely check
> those out.
Actually, we just merged 'em back to trunk so look there instead :)
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Catalyst
mailing list