myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2806] branches/rails2/app/controllers: fixed fil


From: noreply
Subject: [myexperiment-hackers] [2806] branches/rails2/app/controllers: fixed filters that return false to stop the filter chain
Date: Tue, 15 Nov 2011 10:54:35 -0500 (EST)

Revision
2806
Author
dgc
Date
2011-11-15 10:54:34 -0500 (Tue, 15 Nov 2011)

Log Message

fixed filters that return false to stop the filter chain

Modified Paths

Diff

Modified: branches/rails2/app/controllers/blobs_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/blobs_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/blobs_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -307,14 +307,12 @@
       else
         if logged_in? 
           error("File not found (id not authorized)", "is invalid (not authorized)")
-          return false
         else
           find_blob_auth if login_required
         end
       end
     rescue ActiveRecord::RecordNotFound
       error("File not found", "is invalid")
-      return false
     end
   end
   

Modified: branches/rails2/app/controllers/citations_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/citations_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/citations_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -100,7 +100,6 @@
       end
     rescue ActiveRecord::RecordNotFound
       error("Workflow not found", "is invalid")
-      return false
     end
   end
   

Modified: branches/rails2/app/controllers/comments_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/comments_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/comments_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -69,16 +69,20 @@
     @context = extract_resource_context(params)
     @comment = Comment.find_by_id(params[:id])
 
-    return false if @comment.nil? || @context.nil? || @comment.commentable != @context
-    return false if Authorization.is_authorized?('view', nil, @context, current_user) == false
+    return error if @comment.nil? || @context.nil? || @comment.commentable != @context
+    return error if Authorization.is_authorized?('view', nil, @context, current_user) == false
   end
 
   def find_resource_context
 
     @context = extract_resource_context(params)
 
-    return false if @context.nil?
-    return false if Authorization.is_authorized?('view', nil, @context, current_user) == false
+    return error if @context.nil?
+    return error if Authorization.is_authorized?('view', nil, @context, current_user) == false
   end
+
+  def error
+    render :text => 'Error.'
+  end
 end
 

Modified: branches/rails2/app/controllers/content_types_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/content_types_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/content_types_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -74,7 +74,6 @@
 
     if @content_type.nil?
       error("Content type not found", "is invalid")
-      return false
     end
   end
 

Modified: branches/rails2/app/controllers/contributions_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/contributions_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/contributions_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -25,18 +25,20 @@
       @contributable = Object.const_get(klass_name).find_by_id(params[:contributable_id])
 
       # Abort if the contributable does not exist
-      return false if @contributable.nil?
+      return error if @contributable.nil?
 
       # Abort if we're not allowed to see this contributable
-      return false unless Authorization.check(:action ="" 'view', :object => @contributable, :user => current_user)
+      return error unless Authorization.check(:action ="" 'view', :object => @contributable, :user => current_user)
 
     rescue
 
       # In case the const_get doesn't find anything
-      return false
+      return error
     end
+  end
 
-    return true
+  def error
+    render :text => 'Error.'
   end
 end
 

Modified: branches/rails2/app/controllers/friendships_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/friendships_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/friendships_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -186,7 +186,6 @@
     if params[:user_id].blank?
       flash.now[:error] = "Invalid URL"
       redirect_to user_friendships_url(current_user.id)
-      return false
     end
   end
 

Modified: branches/rails2/app/controllers/group_announcements_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/group_announcements_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/group_announcements_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -103,7 +103,6 @@
       @group = Network.find(params[:group_id])
     rescue ActiveRecord::RecordNotFound
       error("Group couldn't be found")
-      return false
     end
   end
 
@@ -111,7 +110,6 @@
   def check_admin
     unless @group.administrator?(current_user.id)
       error("Only group administrators are allowed to create new announcements")
-      return false
     end
   end
 

Modified: branches/rails2/app/controllers/memberships_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/memberships_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/memberships_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -336,7 +336,6 @@
     if params[:user_id].blank?
       flash.now[:error] = "Invalid URL"
       redirect_to user_memberships_url(current_user.id)
-      return false
     end
   end
 

Modified: branches/rails2/app/controllers/oauth_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/oauth_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/oauth_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -172,11 +172,9 @@
         @client_application = client_app
       else
         error("Client Application not found (id not authorized)", "is invalid (not authorized)")
-        return false
       end
     rescue ActiveRecord::RecordNotFound
       error("Client Application not found", "is invalid")
-      return false
     end
   end
 

Modified: branches/rails2/app/controllers/packs_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/packs_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/packs_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -425,11 +425,9 @@
         @base_host = base_host
       else
         error("You are not authorised to perform this action", "is not authorized")
-        return false
       end
     rescue ActiveRecord::RecordNotFound
       error("Pack not found", "is invalid")
-      return false
     end
   end
   

Modified: branches/rails2/app/controllers/previews_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/previews_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/previews_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -84,11 +84,14 @@
 
   def find_context
     @context = extract_resource_context(params)
-    return false unless @context
+    return error unless @context
 
     @context = @context.find_version(params[:version]) if params[:version]
-    return false unless @context
+    return error unless @context
   end
 
+  def error
+    render :text => 'Error.'
+  end
 end
 

Modified: branches/rails2/app/controllers/relationships_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/relationships_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/relationships_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -68,8 +68,8 @@
     @context      = extract_resource_context(params)
     @relationship = Relationship.find_by_id(params[:id])
 
-    return false if @relationship.nil? || @context.nil? || @relationship.context != @context
-    return false if Authorization.is_authorized?('view', nil, @context, current_user) == false
+    return error if @relationship.nil? || @context.nil? || @relationship.context != @context
+    return error if Authorization.is_authorized?('view', nil, @context, current_user) == false
   end
 
   def find_resource_context
@@ -80,5 +80,8 @@
     return false if Authorization.is_authorized?('view', nil, @context, current_user) == false
   end
 
+  def error
+    render :text => 'Error.'
+  end
 end
 

Modified: branches/rails2/app/controllers/reviews_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/reviews_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/reviews_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -135,14 +135,14 @@
       else
         if logged_in?
           error("Workflow not found (id not authorized)", "is invalid (not authorized)")
-          return false
+          return
         else
           login_required
         end
       end
     rescue ActiveRecord::RecordNotFound
       error("Workflow not found", "is invalid")
-      return false
+      return
     end
   end
   
@@ -159,7 +159,7 @@
       @review = review
     else
       error("Review not found", "is invalid")
-      return false
+      return
     end
   end
   
@@ -168,7 +168,7 @@
       @review = review
     else
       error("Review not found or action not authorized", "is invalid (not authorized)")
-      return false
+      return
     end
   end
   

Modified: branches/rails2/app/controllers/search_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/search_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/search_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -21,7 +21,7 @@
 
     if !Conf.search_categories.include?(@type)
       error(@type)
-      return false
+      return
     end
 
     if Conf.model_aliases.key?(@type.camelize.singularize)

Modified: branches/rails2/app/controllers/services_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/services_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/services_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -85,7 +85,6 @@
 
     rescue ActiveRecord::RecordNotFound
       error("Service not found", "is invalid")
-      return false
     end
   end
   

Modified: branches/rails2/app/controllers/user_reports_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/user_reports_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/user_reports_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -37,7 +37,6 @@
 
   def error
     render(:text => '400 Bad Request', :status => "400 Bad Request")
-    false
   end
 end
 

Modified: branches/rails2/app/controllers/userhistory_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/userhistory_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/userhistory_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -32,7 +32,6 @@
     
       rescue ActiveRecord::RecordNotFound
         error("User not found", "is invalid", :user_id)
-        return false
       end
     else
       @user = User.find(params[:id])

Modified: branches/rails2/app/controllers/users_controller.rb (2805 => 2806)


--- branches/rails2/app/controllers/users_controller.rb	2011-11-15 14:32:27 UTC (rev 2805)
+++ branches/rails2/app/controllers/users_controller.rb	2011-11-15 15:54:34 UTC (rev 2806)
@@ -578,17 +578,17 @@
       @user = User.find(params[:id], :include => [ :profile, :tags ])
     rescue ActiveRecord::RecordNotFound
       error("User not found", "is invalid (not owner)")
-      return false
+      return
     end
     
     unless @user
       error("User not found", "is invalid (not owner)")
-      return false
+      return
     end
     
     unless @user.activated?
       error("User not activated", "is invalid (not owner)")
-      return false
+      return
     end
   end
 
@@ -597,17 +597,17 @@
       @user = User.find(params[:id], :conditions => ["id = ?", current_user.id])
     rescue ActiveRecord::RecordNotFound
       error("User not found (id not authorized)", "is invalid (not owner)")
-      return false
+      return
     end
     
     unless @user
       error("User not found (or not authorized)", "is invalid (not owner)")
-      return false
+      return
     end
     
     unless @user.activated?
       error("User not activated (id not authorized)", "is invalid (not owner)")
-      return false
+      return
     end
   end
   

reply via email to

[Prev in Thread] Current Thread [Next in Thread]