[Jifty-commit] r6993 - wifty/trunk/lib/Wifty/Model

Jifty commits jifty-commit at lists.jifty.org
Tue May 12 02:22:32 EDT 2009


Author: ruz
Date: Tue May 12 02:22:32 2009
New Revision: 6993

Modified:
   wifty/trunk/lib/Wifty/Model/Page.pm

Log:
* extend behaviour of current_user_can in array context
* fail the check if IP is blacklisted

Modified: wifty/trunk/lib/Wifty/Model/Page.pm
==============================================================================
--- wifty/trunk/lib/Wifty/Model/Page.pm	(original)
+++ wifty/trunk/lib/Wifty/Model/Page.pm	Tue May 12 02:22:32 2009
@@ -144,10 +144,17 @@
     my $type = shift;
 
     if ($type eq 'create' || $type eq 'update') {
-        return 0 if
+        return wantarray? (0, 'require_auth'): 0 if
          Jifty->config->app('RequireAuth')
            && !$self->current_user->is_superuser
            && !$self->current_user->id;
+
+        if ( my $ip = $ENV{'REMOTE_HOST'} ) {
+            my $block = Jifty->app_class('Model::BlackList')->load_by_cols(
+                type => 'IP', value => $ip
+            );
+            return wantarray? (0, 'black_ip'): 0 if $block && $block->id;
+        }
         return 1;
     } elsif($type eq 'read') {
         return 1;


More information about the Jifty-commit mailing list