Commit 7c6e3d01 authored by Stan Hu's avatar Stan Hu

Only override default if Omnibus protected paths is not enabled

parent ea66022b
......@@ -13,7 +13,9 @@ class ChangeDefaultValueOfThrottleProtectedPaths < ActiveRecord::Migration[5.2]
# 12.4. This migration toggles it back off to ensure we don't
# inadvertently block legitimate users. The admin will have to
# re-enable it in the application settings.
execute "UPDATE application_settings SET throttle_protected_paths_enabled = #{false_value}"
unless omnibus_protected_paths_present?
execute "UPDATE application_settings SET throttle_protected_paths_enabled = #{false_value}"
end
end
def down
......@@ -21,4 +23,16 @@ class ChangeDefaultValueOfThrottleProtectedPaths < ActiveRecord::Migration[5.2]
execute "UPDATE application_settings SET throttle_protected_paths_enabled = #{true_value}"
end
private
def omnibus_protected_paths_present?
Rack::Attack.throttles.key?('protected paths')
rescue e
say "Error while checking if Omnibus protected paths were already enabled: #{e.message}"
say 'Continuing. Protected paths will remain enabled.'
# Return true so we don't take a risk
true
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment