Skip to content

Commit c19b9ec

Browse files
committed
Chore(config): Stop respecting old configuration
`Spree::Config#redirect_back_on_unauthorized` has been removed in Solidus 3.0, and we're on 4.4 now. This can all go. If users have followed the deprecation warnings, then they should be fine with using `redirect_back`. Note that we're not using redirect_back in the admin, as logging out redirects to the admin root controller, which in turn redirects back, leading to an infinite redirect. Infinite redirects are no good.
1 parent 5a8d695 commit c19b9ec

3 files changed

Lines changed: 4 additions & 64 deletions

File tree

lib/spree/auth/engine.rb

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,16 @@ class Engine < Rails::Engine
2626
Spree::Auth::Engine.prepare_frontend if SolidusSupport.frontend_available?
2727
end
2828

29-
def self.redirect_back_on_unauthorized?
30-
return false unless Spree::Config.respond_to?(:redirect_back_on_unauthorized)
31-
32-
if Spree::Config.redirect_back_on_unauthorized
33-
true
34-
else
35-
Spree::Deprecation.warn <<-WARN.strip_heredoc, caller
36-
Having Spree::Config.redirect_back_on_unauthorized set
37-
to `false` is deprecated and will not be supported in Solidus 3.0.
38-
Please change this configuration to `true` and be sure that your
39-
application does not break trying to redirect back when there is
40-
an unauthorized access.
41-
WARN
42-
43-
false
44-
end
45-
end
46-
4729
def self.prepare_backend
4830
Spree::Admin::BaseController.unauthorized_redirect = -> do
4931
if spree_current_user
5032
flash[:error] = I18n.t("spree.authorization_failure")
5133

52-
if Spree::Auth::Engine.redirect_back_on_unauthorized?
53-
redirect_back(fallback_location: spree.admin_unauthorized_path)
54-
else
55-
redirect_to spree.admin_unauthorized_path
56-
end
34+
redirect_to(spree.admin_unauthorized_path)
5735
else
5836
store_location
5937

60-
if Spree::Auth::Engine.redirect_back_on_unauthorized?
61-
redirect_back(fallback_location: spree.admin_login_path)
62-
else
63-
redirect_to spree.admin_login_path
64-
end
38+
redirect_to(spree.admin_login_path)
6539
end
6640
end
6741
end
@@ -71,19 +45,11 @@ def self.prepare_frontend
7145
if spree_current_user
7246
flash[:error] = I18n.t("spree.authorization_failure")
7347

74-
if Spree::Auth::Engine.redirect_back_on_unauthorized?
75-
redirect_back(fallback_location: spree.unauthorized_path)
76-
else
77-
redirect_to spree.unauthorized_path
78-
end
48+
redirect_back(fallback_location: spree.unauthorized_path)
7949
else
8050
store_location
8151

82-
if Spree::Auth::Engine.redirect_back_on_unauthorized?
83-
redirect_back(fallback_location: spree.login_path)
84-
else
85-
redirect_to spree.login_path
86-
end
52+
redirect_back(fallback_location: spree.login_path)
8753
end
8854
end
8955
end

spec/controllers/spree/admin/base_controller_spec.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ def index
1010
end
1111
end
1212

13-
before do
14-
stub_spree_preferences(Spree::Config, redirect_back_on_unauthorized: true)
15-
end
16-
1713
context "when user is logged in" do
1814
before { sign_in(create(:user)) }
1915

@@ -23,15 +19,6 @@ def index
2319
expect(response).to redirect_to(spree.admin_unauthorized_path)
2420
end
2521
end
26-
27-
context "when http_referrer is present" do
28-
before { request.env["HTTP_REFERER"] = "/redirect" }
29-
30-
it "redirects back" do
31-
get :index
32-
expect(response).to redirect_to("/redirect")
33-
end
34-
end
3522
end
3623

3724
context "when user is not logged in" do
@@ -41,15 +28,6 @@ def index
4128
expect(response).to redirect_to(spree.admin_login_path)
4229
end
4330
end
44-
45-
context "when http_referrer is present" do
46-
before { request.env["HTTP_REFERER"] = "/redirect" }
47-
48-
it "redirects back" do
49-
get :index
50-
expect(response).to redirect_to("/redirect")
51-
end
52-
end
5331
end
5432
end
5533
end

spec/controllers/spree/base_controller_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ def index
1010
end
1111
end
1212

13-
before do
14-
stub_spree_preferences(Spree::Config, redirect_back_on_unauthorized: true)
15-
end
16-
1713
context "when user is logged in" do
1814
before { sign_in(create(:user)) }
1915

0 commit comments

Comments
 (0)