From: Simon Cozens Date: Tue, 24 Feb 2004 14:55:23 +0000 (+0000) Subject: "If you set a template in the authenticate method, then the model's action will not... X-Git-Tag: 2.10~290 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=43c803ceb66d273f53b343229ed1ebd6eb0fc142;p=maypole.git "If you set a template in the authenticate method, then the model's action will not be performed. This stops people going to /foo/delete/1 even if they're not logged in. If you want to change the templates based on whether or not the user's logged in, do it in your model action." git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@72 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/lib/Maypole/Model/Base.pm b/lib/Maypole/Model/Base.pm index d092e50..30dacfe 100644 --- a/lib/Maypole/Model/Base.pm +++ b/lib/Maypole/Model/Base.pm @@ -9,12 +9,15 @@ sub edit :Exported { } sub process { my ($class, $r) = @_; my $method = $r->action; - $r->{template} ||= $method; # Authentication may have done this for us - $r->objects([ $class->retrieve(shift @{$r->{args}}) ]); - - # This allows the authentication mechanism to set the template - # without needing to define an action. - $class->$method($r) if $class->can($method); + return if $r->{template}; # Authentication has set this, we're done. + + $r->{template} = $method; + my $obj = $class->retrieve( $r->{args}->[0] ); + if ($obj) { + $r->objects([ $obj ]); + shift @{$r->{args}}; + } + $class->$method($r); } sub display_columns {