Skip to content

Commit aa75c33

Browse files
committed
Utilize SolidusAuthDevise redirect helpers
With the deprecation of #redirect_back_or_default in solidus 4.0, we can utilize the SolidusAuthDevise helper stored_location_for to provide the same functionality.
1 parent c6ef4e6 commit aa75c33

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/controllers/spree/omniauth_callbacks_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def provides_callback_for(*providers)
2121
def omniauth_callback
2222
if request.env['omniauth.error'].present?
2323
flash[:error] = I18n.t('devise.omniauth_callbacks.failure', kind: auth_hash['provider'], reason: I18n.t('spree.user_was_not_valid'))
24-
redirect_back_or_default(root_url)
24+
redirect_to stored_spree_user_location_or(root_url)
2525
return
2626
end
2727

@@ -34,7 +34,7 @@ def omniauth_callback
3434
spree_current_user.apply_omniauth(auth_hash)
3535
spree_current_user.save!
3636
flash[:notice] = I18n.t('devise.sessions.signed_in')
37-
redirect_back_or_default(account_url)
37+
redirect_to stored_spree_user_location_or(account_url)
3838
else
3939
user = Spree.user_class.find_by(email: auth_hash['info']['email']) || Spree.user_class.new
4040
user.apply_omniauth(auth_hash)

spec/controllers/spree/omniauth_callbacks_controller_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
Rails.application.routes.default_url_options[:host] = 'test.host'
1010
request.env['omniauth.auth'] = omni_params
1111
allow(controller).to receive(:sign_in_and_redirect)
12-
allow(controller).to receive(:redirect_back_or_default)
12+
allow(controller).to receive(:redirect_to)
1313
allow(Spree::User).to receive(:anonymous!).with(user)
1414
end
1515

1616
shared_examples_for 'denied_permissions' do
1717
before { request.env['omniauth.error'] = 'FAIL' }
1818

1919
it 'redirects properly' do
20-
expect(controller).to receive(:redirect_back_or_default)
20+
expect(controller).to receive(:redirect_to)
2121
controller.github
2222
end
2323

@@ -95,7 +95,7 @@
9595
end
9696

9797
it 'redirects properly' do
98-
expect(controller).to receive(:redirect_back_or_default)
98+
expect(controller).to receive(:redirect_to)
9999
controller.github
100100
end
101101

0 commit comments

Comments
 (0)