2659: Check anon config at runtime instead of boot time in skip_before_filter. This...
authorTom Clegg <tom@curoverse.com>
Tue, 3 Feb 2015 21:33:18 +0000 (16:33 -0500)
committerTom Clegg <tom@curoverse.com>
Tue, 3 Feb 2015 21:33:18 +0000 (16:33 -0500)
apps/workbench/app/controllers/collections_controller.rb
apps/workbench/app/controllers/jobs_controller.rb
apps/workbench/app/controllers/pipeline_instances_controller.rb
apps/workbench/app/controllers/pipeline_templates_controller.rb
apps/workbench/app/controllers/projects_controller.rb

index 36c214c7da8106145a1142fd2d39a8a74a26a776..613ed98f88cc22fb83ee65b3870b20605c5ce419 100644 (file)
@@ -3,13 +3,12 @@ require "arvados/keep"
 class CollectionsController < ApplicationController
   include ActionController::Live
 
-  if Rails.configuration.anonymous_user_token
-    skip_around_filter(:require_thread_api_token,
-                       only: [:show_file, :show_file_links, :show])
-  else
-    skip_around_filter(:require_thread_api_token,
-                       only: [:show_file, :show_file_links])
-  end
+  skip_around_filter :require_thread_api_token, if: proc { |ctrl|
+    Rails.configuration.anonymous_user_token and
+    'show' == ctrl.action_name
+  }
+  skip_around_filter(:require_thread_api_token,
+                     only: [:show_file, :show_file_links])
   skip_before_filter(:find_object_by_uuid,
                      only: [:provenance, :show_file, :show_file_links])
   # We depend on show_file to display the user agreement:
index 9090d6404aac4b49f32f1414933cf598a46a37c5..b90210f6a9b7be4c7bbea8a1193000ac9e8a7a56 100644 (file)
@@ -1,7 +1,8 @@
 class JobsController < ApplicationController
-  if Rails.configuration.anonymous_user_token
-    skip_around_filter :require_thread_api_token, only: :show
-  end
+  skip_around_filter :require_thread_api_token, if: proc { |ctrl|
+    Rails.configuration.anonymous_user_token and
+    'show' == ctrl.action_name
+  }
 
   include JobsHelper
 
index 2f875edf255bbbee2cfe532ddf6a020050d88c3e..b4cce9be03e42bd2899590101a671717deb6295b 100644 (file)
@@ -1,9 +1,10 @@
 class PipelineInstancesController < ApplicationController
   skip_before_filter :find_object_by_uuid, only: :compare
   before_filter :find_objects_by_uuid, only: :compare
-  if Rails.configuration.anonymous_user_token
-    skip_around_filter :require_thread_api_token, only: :show
-  end
+  skip_around_filter :require_thread_api_token, if: proc { |ctrl|
+    Rails.configuration.anonymous_user_token and
+    'show' == ctrl.action_name
+  }
 
   include PipelineInstancesHelper
   include PipelineComponentsHelper
index eb5f3793d71b3042cc3fa1138f057c7c3ff9302b..83ab88f6122dd1e5234bb12e4978fbabe89b263f 100644 (file)
@@ -1,7 +1,8 @@
 class PipelineTemplatesController < ApplicationController
-  if Rails.configuration.anonymous_user_token
-    skip_around_filter :require_thread_api_token, only: :show
-  end
+  skip_around_filter :require_thread_api_token, if: proc { |ctrl|
+    Rails.configuration.anonymous_user_token and
+    'show' == ctrl.action_name
+  }
 
   include PipelineComponentsHelper
 
index d0c5f8c307e620f22f03029c911f87b2ddc2d81d..abba785f07247723d6a58439acf923b37390334e 100644 (file)
@@ -1,8 +1,9 @@
 class ProjectsController < ApplicationController
   before_filter :set_share_links, if: -> { defined? @object }
-  if Rails.configuration.anonymous_user_token
-    skip_around_filter :require_thread_api_token, only: [:show, :tab_counts]
-  end
+  skip_around_filter :require_thread_api_token, if: proc { |ctrl|
+    Rails.configuration.anonymous_user_token and
+    %w(show tab_counts).include? ctrl.action_name
+  }
 
   def model_class
     Group