Skip to content

Commit

Permalink
Use fullpage redirect for billing in embedded apps
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillplatonov committed Nov 14, 2022
1 parent c63b306 commit 35d8772
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Unreleased
----------
* Fixes a bug with `EnsureAuthenticatedLinks` causing deep links to not work [#1549](https://github.com/Shopify/shopify_app/pull/1549)
* Ensure online token is properly used when using `current_shopify_session` [#1566](https://github.com/Shopify/shopify_app/pull/1566)
* Fixes a bug with `EnsureBilling` causing infinite redirect in embedded apps [#1578](https://github.com/Shopify/shopify_app/pull/1578)

21.2.0 (Oct 25, 2022)
----------
Expand Down
2 changes: 2 additions & 0 deletions lib/shopify_app/controller_concerns/ensure_billing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def check_billing(session = current_shopify_session)
if request.xhr?
add_top_level_redirection_headers(url: confirmation_url, ignore_response_code: true)
head(:unauthorized)
elsif ShopifyApp.configuration.embedded_app?
fullpage_redirect_to(confirmation_url)
else
redirect_to(confirmation_url, allow_other_host: true)
end
Expand Down
12 changes: 9 additions & 3 deletions test/controllers/concerns/ensure_billing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def index

get :index

assert_redirected_to(%r{^https://totally-real-url})
assert_response :success
assert_match "Redirecting", response.body
assert_match(%r{https://totally-real-url}, response.body)

get :index, xhr: true

Expand Down Expand Up @@ -96,7 +98,9 @@ def index

get :index

assert_redirected_to(%r{^https://totally-real-url})
assert_response :success
assert_match "Redirecting", response.body
assert_match(%r{https://totally-real-url}, response.body)

get :index, xhr: true

Expand Down Expand Up @@ -162,7 +166,9 @@ def index

get :index

assert_redirected_to(%r{^https://totally-real-url})
assert_response :success
assert_match "Redirecting", response.body
assert_match(%r{https://totally-real-url}, response.body)

get :index, xhr: true

Expand Down

0 comments on commit 35d8772

Please sign in to comment.