From e5eb68dffc2b6fa336aa919fa29d1c382cc26edc Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Mon, 19 Apr 2021 12:49:01 +0200 Subject: [PATCH] Replace duplicate method with module inclusion No reason to risk diverging their implementations. They are exact copies. Likewise, there's no need to have to I18n keys with almost the same content. --- app/controllers/spree/admin/base_controller.rb | 12 ------------ config/locales/en.yml | 1 - lib/spree/core/controller_helpers/auth.rb | 2 +- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/app/controllers/spree/admin/base_controller.rb b/app/controllers/spree/admin/base_controller.rb index 8d002b583c..395baa538e 100644 --- a/app/controllers/spree/admin/base_controller.rb +++ b/app/controllers/spree/admin/base_controller.rb @@ -21,18 +21,6 @@ module Spree flash[:notice] = warning if warning.present? end - # This is in Spree::Core::ControllerHelpers::Auth - # But you can't easily reopen modules in Ruby - def unauthorized - if spree_current_user - flash[:error] = t(:authorization_failure) - redirect_to '/unauthorized' - else - store_location - redirect_to main_app.root_path(anchor: "login?after_login=#{request.env['PATH_INFO']}") - end - end - protected def model_class diff --git a/config/locales/en.yml b/config/locales/en.yml index 52bf5aa3b3..9871f1d17e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3093,7 +3093,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using adjustment: "Adjustment" all: "All" associated_adjustment_closed: "Associated adjustment closed" - authorization_failure: "Authorization failure" back_to_adjustments_list: "Back to adjustments" back_to_users_list: "Back to users" back_to_zones_list: "Back to zones" diff --git a/lib/spree/core/controller_helpers/auth.rb b/lib/spree/core/controller_helpers/auth.rb index fc2c1201e3..85c4e91095 100644 --- a/lib/spree/core/controller_helpers/auth.rb +++ b/lib/spree/core/controller_helpers/auth.rb @@ -25,7 +25,7 @@ module Spree # For example, a popup window might simply close itself. def unauthorized if spree_current_user - flash[:error] = Spree.t(:authorization_failure) + flash[:error] = t(:authorization_failure) redirect_to '/unauthorized' else store_location