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.
This commit is contained in:
Pau Perez
2021-04-19 12:49:01 +02:00
parent 9bddf5b00f
commit e5eb68dffc
3 changed files with 1 additions and 14 deletions

View File

@@ -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

View File

@@ -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"

View File

@@ -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