diff --git a/src/ShopifyApp/Actions/AuthenticateShop.php b/src/ShopifyApp/Actions/AuthenticateShop.php index fb69cb82..bc57cc50 100644 --- a/src/ShopifyApp/Actions/AuthenticateShop.php +++ b/src/ShopifyApp/Actions/AuthenticateShop.php @@ -88,6 +88,7 @@ public function __invoke(Request $request): array ShopDomain::fromNative($request->get('shop')), $request->query('code') ); + if (! $result['completed']) { // No code, redirect to auth URL return [$result, false]; diff --git a/src/ShopifyApp/Exceptions/MissingAuthUrlException.php b/src/ShopifyApp/Exceptions/MissingAuthUrlException.php new file mode 100644 index 00000000..2da82af6 --- /dev/null +++ b/src/ShopifyApp/Exceptions/MissingAuthUrlException.php @@ -0,0 +1,10 @@ +getRequestUri(), '/authenticate')) { + // Continue if current route is an auth or billing route + if (Str::startsWith($request->getRequestUri(), ['/authenticate', '/billing'])) { return $next($request); } - // Get the token (if available) - $tokenSource = $request->ajax() ? $request->bearerToken() : $request->get('token'); + $tokenSource = getAccessTokenFromRequest($request); + if ($tokenSource === null) { // Not available, we need to get one return $this->handleMissingToken($request); diff --git a/src/ShopifyApp/resources/config/shopify-app.php b/src/ShopifyApp/resources/config/shopify-app.php index 2c0c36b9..fc5610fa 100644 --- a/src/ShopifyApp/resources/config/shopify-app.php +++ b/src/ShopifyApp/resources/config/shopify-app.php @@ -383,4 +383,14 @@ */ 'config_api_callback' => null, + + /* + |-------------------------------------------------------------------------- + | Enable Turbolinks or Hotwire Turbo + |-------------------------------------------------------------------------- + | + | If you use Turbolinks / Turbo And Livewire turn on this setting to get the token + | + */ + 'turbo_enabled' => false, ]; diff --git a/src/ShopifyApp/resources/views/layouts/default.blade.php b/src/ShopifyApp/resources/views/layouts/default.blade.php index c900b1df..4325f5aa 100644 --- a/src/ShopifyApp/resources/views/layouts/default.blade.php +++ b/src/ShopifyApp/resources/views/layouts/default.blade.php @@ -28,6 +28,19 @@ forceRedirect: true, }); + @if(\Osiset\ShopifyApp\getShopifyConfig('turbo_enabled')) + + @endif @include('shopify-app::partials.flash_messages') @endif