From 89cfb2b908eeb1faef18dac5b59b0f2f47b5383e Mon Sep 17 00:00:00 2001 From: Nabeel Ahsen Date: Fri, 22 Jan 2021 10:23:09 -0500 Subject: [PATCH] Redirect EnsureAuthenticatedLinks to login page if current_shopify_domain not found --- .../concerns/shopify_app/ensure_authenticated_links.rb | 2 ++ .../concerns/ensure_authenticated_links_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb b/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb index acddeb537..a5c4122ee 100644 --- a/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb +++ b/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb @@ -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? diff --git a/test/controllers/concerns/ensure_authenticated_links_test.rb b/test/controllers/concerns/ensure_authenticated_links_test.rb index f6f6231b2..d8bc9935e 100644 --- a/test/controllers/concerns/ensure_authenticated_links_test.rb +++ b/test/controllers/concerns/ensure_authenticated_links_test.rb @@ -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