diff --git a/src/Http/Middleware/EnsureShopifyInstalled.php b/src/Http/Middleware/EnsureShopifyInstalled.php index f76e090..709eee0 100644 --- a/src/Http/Middleware/EnsureShopifyInstalled.php +++ b/src/Http/Middleware/EnsureShopifyInstalled.php @@ -22,7 +22,10 @@ public function handle(Request $request, Closure $next) { $shop = $request->query('shop') ? Utils::sanitizeShopDomain($request->query('shop')) : null; - $appInstalled = $shop && ShopifySession::where('shop', $shop)->where('access_token', '<>', null)->where('scope', Context::$SCOPES->toString())->exists(); + $session = Utils::loadOfflineSession($shop); + + $appInstalled = !empty($session); + $isExitingIframe = preg_match('/^ExitIframe/i', $request->path()); if ($isExitingIframe) { @@ -35,8 +38,6 @@ public function handle(Request $request, Closure $next) event(new ShopifyAppInstalled($shop)); } - $session ??= Utils::loadOfflineSession($shop); - if (config('shopify-integration.billing.required')) { [$hasPayment, $confirmationUrl] = EnsureBilling::check( $session,