diff --git a/src/Http/Middleware/VerifyShopify.php b/src/Http/Middleware/VerifyShopify.php index f2f29cd7..4818e5cb 100644 --- a/src/Http/Middleware/VerifyShopify.php +++ b/src/Http/Middleware/VerifyShopify.php @@ -377,20 +377,9 @@ protected function getHmacFromRequest(Request $request): array */ protected function getAccessTokenFromRequest(Request $request): ?string { - if (Util::getShopifyConfig('turbo_enabled')) { - if ($request->bearerToken()) { - // Bearer tokens collect. - // Turbo does not refresh the page, values are attached to the same header. - $bearerTokens = Collection::make(explode(',', $request->header('Authorization', ''))); - $newestToken = Str::substr(trim($bearerTokens->last()), 7); - - return $newestToken; - } - - return $request->get('token'); - } - - return $this->isApiRequest($request) ? $request->bearerToken() : $request->get('token'); + return $this->isApiRequest($request) + ? $request->bearerToken() + : $request->get('token'); } /** diff --git a/src/Traits/AuthController.php b/src/Traits/AuthController.php index ab443566..4d034079 100644 --- a/src/Traits/AuthController.php +++ b/src/Traits/AuthController.php @@ -64,8 +64,7 @@ public function authenticate(Request $request, AuthenticateShop $authShop) 'shopify-app::auth.fullpage_redirect', [ 'apiKey' => Util::getShopifyConfig('api_key', $shopOrigin), - 'appBridgeVersion' => Util::getShopifyConfig('appbridge_version') ? '@'.config('shopify-app.appbridge_version') : '', - 'authUrl' => $result['url'], + 'url' => $result['url'], 'host' => $request->get('host'), 'shopDomain' => $shopDomain, 'locale' => $request->get('locale'), diff --git a/src/resources/config/shopify-app.php b/src/resources/config/shopify-app.php index 6acbfd7a..34770d10 100644 --- a/src/resources/config/shopify-app.php +++ b/src/resources/config/shopify-app.php @@ -37,7 +37,6 @@ */ 'domain' => env('SHOPIFY_DOMAIN'), - /* |-------------------------------------------------------------------------- | Manual routes @@ -138,26 +137,6 @@ 'prefix' => env('SHOPIFY_APP_PREFIX', ''), - /* - |-------------------------------------------------------------------------- - | AppBridge Mode - |-------------------------------------------------------------------------- - | - | AppBridge (embedded apps) are enabled by default. Set to false to use legacy - | mode and host the app inside your own container. - | - */ - - 'appbridge_enabled' => (bool) env('SHOPIFY_APPBRIDGE_ENABLED', true), - - // Use semver range to link to a major or minor version number. - // Leaving empty will use the latest version - not recommended in production. - 'appbridge_version' => env('SHOPIFY_APPBRIDGE_VERSION', 'latest'), - - // Set a new CDN URL if you want to host the AppBridge JS yourself or unpkg goes down. - // DO NOT include a trailing slash. - 'appbridge_cdn_url' => env('SHOPIFY_APPBRIDGE_CDN_URL', 'https://unpkg.com'), - /* |-------------------------------------------------------------------------- | Shopify App Name @@ -513,18 +492,6 @@ 'config_api_callback' => null, - /* - |-------------------------------------------------------------------------- - | Enable Turbolinks or Hotwire Turbo - |-------------------------------------------------------------------------- - | - | If you use Turbolinks/Turbo and Livewire, turn on this setting to get - | the token assigned automatically. - | - */ - - 'turbo_enabled' => (bool) env('SHOPIFY_TURBO_ENABLED', false), - /* |-------------------------------------------------------------------------- | Customize Models and Table Name diff --git a/src/resources/views/auth/fullpage_redirect.blade.php b/src/resources/views/auth/fullpage_redirect.blade.php index 8ed3435d..0811f501 100644 --- a/src/resources/views/auth/fullpage_redirect.blade.php +++ b/src/resources/views/auth/fullpage_redirect.blade.php @@ -3,32 +3,19 @@ + + Redirecting... - diff --git a/src/resources/views/auth/token.blade.php b/src/resources/views/auth/token.blade.php index 8433d57f..797f5b8e 100644 --- a/src/resources/views/auth/token.blade.php +++ b/src/resources/views/auth/token.blade.php @@ -34,13 +34,31 @@ @section('scripts') @parent - - @if(config('shopify-app.appbridge_enabled')) - @endif @endsection diff --git a/src/resources/views/billing/fullpage_redirect.blade.php b/src/resources/views/billing/fullpage_redirect.blade.php index 300d96d4..e14175f0 100644 --- a/src/resources/views/billing/fullpage_redirect.blade.php +++ b/src/resources/views/billing/fullpage_redirect.blade.php @@ -3,24 +3,21 @@ + + Redirecting... - + diff --git a/src/resources/views/home/index.blade.php b/src/resources/views/home/index.blade.php index 633a6b3d..5ab6e32b 100644 --- a/src/resources/views/home/index.blade.php +++ b/src/resources/views/home/index.blade.php @@ -5,6 +5,8 @@ @endsection @section('content') + +
@@ -17,20 +19,10 @@

 

@endsection - -@section('scripts') - @parent - - @if(config('shopify-app.appbridge_enabled')) - - @endif -@endsection diff --git a/src/resources/views/layouts/default.blade.php b/src/resources/views/layouts/default.blade.php index 313e2bfd..854af9fd 100644 --- a/src/resources/views/layouts/default.blade.php +++ b/src/resources/views/layouts/default.blade.php @@ -3,8 +3,10 @@ + + - {{ \Osiset\ShopifyApp\Util::getShopifyConfig('app_name') }} + {{ config('shopify-app.app_name') }} @yield('styles') @@ -17,28 +19,9 @@
- @if(\Osiset\ShopifyApp\Util::getShopifyConfig('appbridge_enabled') && \Osiset\ShopifyApp\Util::useNativeAppBridge()) - - - + @if(\Osiset\ShopifyApp\Util::useNativeAppBridge()) @include('shopify-app::partials.token_handler') - @include('shopify-app::partials.flash_messages') @endif - @yield('scripts') diff --git a/src/resources/views/partials/flash_messages.blade.php b/src/resources/views/partials/flash_messages.blade.php deleted file mode 100644 index 5298a344..00000000 --- a/src/resources/views/partials/flash_messages.blade.php +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/src/resources/views/partials/token_handler.blade.php b/src/resources/views/partials/token_handler.blade.php index a13efaf6..a9194b2d 100644 --- a/src/resources/views/partials/token_handler.blade.php +++ b/src/resources/views/partials/token_handler.blade.php @@ -1,18 +1,15 @@ - diff --git a/tests/Traits/AuthControllerTest.php b/tests/Traits/AuthControllerTest.php index a435c7c9..23167a23 100644 --- a/tests/Traits/AuthControllerTest.php +++ b/tests/Traits/AuthControllerTest.php @@ -30,7 +30,7 @@ public function testAuthRedirectsToShopifyWhenNoCode(): void // Check the redirect happens and location is set properly in the header. $response->assertViewHas('shopDomain', 'example.myshopify.com'); $response->assertViewHas( - 'authUrl', + 'url', 'https://example.myshopify.com/admin/oauth/authorize?client_id='.Util::getShopifyConfig('api_key').'&scope=read_products%2Cwrite_products%2Cread_themes&redirect_uri=https%3A%2F%2Flocalhost%2Fauthenticate' ); diff --git a/tests/Traits/BillingControllerTest.php b/tests/Traits/BillingControllerTest.php index c3011fc9..1ddb89f3 100644 --- a/tests/Traits/BillingControllerTest.php +++ b/tests/Traits/BillingControllerTest.php @@ -45,6 +45,7 @@ public function testSendsShopToBillingScreen(): void // Run the call $response = $this->call('get', '/billing', ['shop' => $shop->getDomain()->toNative()]); + $response->assertViewHas( 'url', 'https://example.myshopify.com/admin/charges/1029266947/confirm_recurring_application_charge?signature=BAhpBANeWT0%3D--64de8739eb1e63a8f848382bb757b20343eb414f' diff --git a/tests/Traits/HomeControllerTest.php b/tests/Traits/HomeControllerTest.php index 934c3b18..b34b5eb1 100644 --- a/tests/Traits/HomeControllerTest.php +++ b/tests/Traits/HomeControllerTest.php @@ -27,18 +27,18 @@ public function testHomeRoute(): void $host = base64_encode($shop->getDomain()->toNative().'/admin'); $this->call('get', '/', ['token' => $this->buildToken(), 'host' => $host]) ->assertOk() - ->assertSee('apiKey: "'.Util::getShopifyConfig('api_key').'"', false) - ->assertSee("host: \"{$host}\"", false); + ->assertSee('name="shopify-api-key" content="'.Util::getShopifyConfig('api_key').'"', false) + ->assertSee('https://cdn.shopify.com/shopifycloud/app-bridge.js'); } public function testHomeRouteHostAdmin(): void { - $shop = factory($this->model)->create(['name' => 'shop-name.myshopify.com']); + factory($this->model)->create(['name' => 'shop-name.myshopify.com']); $host = base64_encode('admin.shopify.com/store/shop-name'); $this->call('get', '/', ['token' => $this->buildToken(), 'host' => $host]) ->assertOk() - ->assertSee('apiKey: "'.Util::getShopifyConfig('api_key').'"', false) - ->assertSee("host: \"{$host}\"", false); + ->assertSee('name="shopify-api-key" content="'.Util::getShopifyConfig('api_key').'"', false) + ->assertSee('https://cdn.shopify.com/shopifycloud/app-bridge.js'); } }