Skip to content

Commit

Permalink
Redirect EnsureAuthenticatedLinks to login page if current_shopify_do…
Browse files Browse the repository at this point in the history
…main not found
  • Loading branch information
NabeelAhsen committed Jan 22, 2021
1 parent c9e2257 commit 6c5a46e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module EnsureAuthenticatedLinks
def redirect_to_splash_page
splash_page_path = root_path(return_to: request.fullpath, shop: current_shopify_domain)
redirect_to(splash_page_path)
rescue ShopifyApp::LoginProtection::ShopifyDomainNotFound
redirect_to(ShopifyApp.configuration.login_url)
end

def missing_expected_jwt?
Expand Down
8 changes: 8 additions & 0 deletions test/controllers/concerns/ensure_authenticated_links_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,12 @@ def current_shopify_domain

assert_response :ok
end

test 'redirects to login page if current shopify domain is not found' do
@controller.expects(:current_shopify_domain).raises(ShopifyApp::LoginProtection::ShopifyDomainNotFound)

get :some_link

assert_redirected_to ShopifyApp.configuration.login_url
end
end

0 comments on commit 6c5a46e

Please sign in to comment.