From 43c803ceb66d273f53b343229ed1ebd6eb0fc142 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Tue, 24 Feb 2004 14:55:23 +0000 Subject: [PATCH] "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 --- lib/Maypole/Model/Base.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 { -- 2.39.2