From 9ad78396f7de9ab066c75135daa7ea41233dcc01 Mon Sep 17 00:00:00 2001 From: vdubov Date: Sun, 24 Jul 2022 20:06:59 +0400 Subject: [PATCH 01/17] update config, add spa variable --- src/resources/config/shopify-app.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/resources/config/shopify-app.php b/src/resources/config/shopify-app.php index 13338313..c4a3ab2e 100644 --- a/src/resources/config/shopify-app.php +++ b/src/resources/config/shopify-app.php @@ -470,5 +470,15 @@ * The table name for Plan model. */ 'plans' => 'plans', - ] + ], + + /* + |-------------------------------------------------------------------------- + | Determines whether the SPA is used + |-------------------------------------------------------------------------- + | + | If you use SPA (React or Vue), you don't need a redirect to the JWT token retrieval page + | + */ + 'spa_frontend_used' => (bool) env('SHOPIFY_SPA_FRONTEND_USED', false), ]; From cfb1d5f4b7027f103968b86d1180f8b4a9446c6a Mon Sep 17 00:00:00 2001 From: vdubov Date: Sun, 24 Jul 2022 20:08:38 +0400 Subject: [PATCH 02/17] Continue if app already installed and has access token and not deleted --- src/Http/Middleware/VerifyShopify.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Http/Middleware/VerifyShopify.php b/src/Http/Middleware/VerifyShopify.php index 4cd8d635..dfe49319 100644 --- a/src/Http/Middleware/VerifyShopify.php +++ b/src/Http/Middleware/VerifyShopify.php @@ -101,6 +101,14 @@ public function handle(Request $request, Closure $next) return $next($request); } + if (Util::getShopifyConfig('spa_frontend_used')) { + $storeResult = $this->checkPreviousInstallation($request); + + if ($storeResult) { + return $next($request); + } + } + $tokenSource = $this->getAccessTokenFromRequest($request); if ($tokenSource === null) { //Check if there is a store record in the database From 62158d777b5fe65de97280a5241f4553f7b3e90e Mon Sep 17 00:00:00 2001 From: vdubov Date: Sun, 24 Jul 2022 20:15:29 +0400 Subject: [PATCH 03/17] disable cdn app bridge if spa used --- src/resources/views/layouts/default.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/views/layouts/default.blade.php b/src/resources/views/layouts/default.blade.php index 6c73a662..e21839b9 100644 --- a/src/resources/views/layouts/default.blade.php +++ b/src/resources/views/layouts/default.blade.php @@ -17,7 +17,7 @@ - @if(\Osiset\ShopifyApp\Util::getShopifyConfig('appbridge_enabled')) + @if(\Osiset\ShopifyApp\Util::getShopifyConfig('appbridge_enabled') && !\Osiset\ShopifyApp\Util::getShopifyConfig('spa_frontend_used'))