[Jifty-commit] r3300 - in jifty/trunk: lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu May 24 14:51:01 EDT 2007


Author: falcone
Date: Thu May 24 14:51:00 2007
New Revision: 3300

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Action.pm
   jifty/trunk/lib/Jifty/Web.pm

Log:
 r18975 at ketch:  falcone | 2007-05-24 14:50:30 -0400
 * add data to the result indicating which requested actions
   were denied and mark them failed.  Options for a better
   denied message coming soon


Modified: jifty/trunk/lib/Jifty/Action.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action.pm	(original)
+++ jifty/trunk/lib/Jifty/Action.pm	Thu May 24 14:51:00 2007
@@ -1105,6 +1105,27 @@
 
 }
 
+=head2 deny REASON
+
+When access to an action is denied by L<Jifty::API::is_allowed> 
+the request handler calls this with a message.
+
+This should mark the action as failed and store the message
+but may also want to do other things (such as providing a nicer message
+or logging somewhere other than the jifty logs)
+
+=cut
+
+sub deny {
+    my $self = shift;
+    my $message = shift||'';
+
+    $self->result->failure(1);
+    $self->result->message($message);
+
+    return;
+}
+
 =head2 autogenerated
 
 Autogenerated Actions will always return true when this method is called. 

Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm	(original)
+++ jifty/trunk/lib/Jifty/Web.pm	Thu May 24 14:51:00 2007
@@ -302,6 +302,7 @@
     die _( "No request to handle" ) unless Jifty->web->request;
 
     my @valid_actions;
+    my @denied_actions;
     for my $request_action ( $self->request->actions ) {
         $self->log->debug("Found action ".$request_action->class . " " . $request_action->moniker);
         next unless $request_action->active;
@@ -310,6 +311,7 @@
             $self->log->warn( "Attempt to call denied action '"
                     . $request_action->class
                     . "'" );
+            push @denied_actions, $request_action;
             next;
         }
 
@@ -370,6 +372,11 @@
             # may have yielded.
             $self->request->do_mapping;
         }
+        for my $request_action (@denied_actions) {
+            my $action = $self->new_action_from_request($request_action);
+            $action->deny("Access Denied for ".ref($action));
+            $self->response->result( $action->moniker => $action->result );
+        }
     }
 
     # If there's a continuation call, don't do the rest of this


More information about the Jifty-commit mailing list