Skip to content

Commit 2fd002d

Browse files
committed
Handle invalid token when adding redirection headers
1 parent ef63ee3 commit 2fd002d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/shopify_app/controller_concerns/login_protection.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,13 @@ def add_top_level_redirection_headers(url: nil, ignore_response_code: false)
8989
current_shopify_session.shop
9090

9191
elsif shopify_id_token
92-
jwt_payload = ShopifyAPI::Auth::JwtPayload.new(shopify_id_token)
93-
jwt_payload.shop
92+
begin
93+
jwt_payload = ShopifyAPI::Auth::JwtPayload.new(shopify_id_token)
94+
jwt_payload.shop
95+
rescue ShopifyAPI::Errors::InvalidJwtTokenError
96+
ShopifyApp::Logger.warn("Invalid JWT token for current Shopify session")
97+
nil
98+
end
9499
end
95100
end
96101

0 commit comments

Comments
 (0)