Skip to content

Commit e5e8741

Browse files
committed
Fix error where wrong scopes order would result in failing check if app already installed
1 parent 3ff9d55 commit e5e8741

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Http/Middleware/EnsureShopifyInstalled.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ public function handle(Request $request, Closure $next)
2222
{
2323
$shop = $request->query('shop') ? Utils::sanitizeShopDomain($request->query('shop')) : null;
2424

25-
$appInstalled = $shop && ShopifySession::where('shop', $shop)->where('access_token', '<>', null)->where('scope', Context::$SCOPES->toString())->exists();
25+
$session = Utils::loadOfflineSession($shop);
26+
27+
$appInstalled = !empty($session);
28+
2629
$isExitingIframe = preg_match('/^ExitIframe/i', $request->path());
2730

2831
if ($isExitingIframe) {
@@ -35,8 +38,6 @@ public function handle(Request $request, Closure $next)
3538
event(new ShopifyAppInstalled($shop));
3639
}
3740

38-
$session ??= Utils::loadOfflineSession($shop);
39-
4041
if (config('shopify-integration.billing.required')) {
4142
[$hasPayment, $confirmationUrl] = EnsureBilling::check(
4243
$session,

0 commit comments

Comments
 (0)