Business intelligence made simple
Prompt developers to check custom before_action
Andrew82b95a27ae65
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b1857add..83907a65 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,6 @@-## 1.8.3 [unreleased]+## 1.9.0 [unreleased]+- Prompt developers to check custom `before_action`- Better ordering on home page- Added support for Snowflakediff --git a/README.md b/README.mdindex ea7a1af0..add0c3cf 100644--- a/README.md+++ b/README.md@@ -151,7 +151,7 @@ endSpecify a `before_action` method to run in `blazer.yml`.```yml-before_action: require_admin+before_action_method: require_admin```You can define this method in your `ApplicationController`.diff --git a/app/controllers/blazer/base_controller.rb b/app/controllers/blazer/base_controller.rbindex c9a5a82e..35a2ccbe 100644--- a/app/controllers/blazer/base_controller.rb+++ b/app/controllers/blazer/base_controller.rb@@ -16,6 +16,10 @@ module Blazerhttp_basic_authenticate_with name: ENV["BLAZER_USERNAME"], password: ENV["BLAZER_PASSWORD"]end+ if Blazer.settings["before_action"]+ raise Blazer::Error, "The docs for protecting Blazer with a custom before_action had an incorrect example from August 2017 to June 2018. The example method had a boolean return value. However, you must render or redirect if a user is unauthorized rather than return a falsy value. Double check that your before_action works correctly for unauthorized users (if it worked when added, there should be no issue). Then, change before_action to before_action_method in config/blazer.yml."+ end+if Blazer.before_actionbefore_action Blazer.before_action.to_symenddiff --git a/lib/blazer/engine.rb b/lib/blazer/engine.rbindex 61d46505..71317293 100644--- a/lib/blazer/engine.rb+++ b/lib/blazer/engine.rb@@ -11,7 +11,7 @@ module BlazerBlazer.audit = Blazer.settings.key?("audit") ? Blazer.settings["audit"] : trueBlazer.user_name = Blazer.settings["user_name"] if Blazer.settings["user_name"]Blazer.from_email = Blazer.settings["from_email"] if Blazer.settings["from_email"]- Blazer.before_action = Blazer.settings["before_action"] if Blazer.settings["before_action"]+ Blazer.before_action = Blazer.settings["before_action_method"] if Blazer.settings["before_action_method"]Blazer.check_schedules = Blazer.settings["check_schedules"] if Blazer.settings.key?("check_schedules")Blazer.cache ||= Rails.cachediff --git a/lib/generators/blazer/templates/config.yml b/lib/generators/blazer/templates/config.ymlindex d7e891ef..007ef94b 100644--- a/lib/generators/blazer/templates/config.yml+++ b/lib/generators/blazer/templates/config.yml@@ -47,8 +47,8 @@ audit: true# method name for the display name# user_name: name-# optional auth method to use as a before_action (default: nil)-# before_action: require_admin+# custom before_action to use for auth+# before_action_method: require_admin# email to send checks from# from_email: [email protected]