From 7e3d24d553acdcdb85a4539fedcaba58f438e340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Corr=C3=AAa=20Gomes?= Date: Wed, 6 Sep 2023 16:27:31 -0400 Subject: [PATCH] Fix #143 - Could not find the current session id in the cookies Fix 143 --- web/routes/web.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/web/routes/web.php b/web/routes/web.php index b882edc4..eccf2983 100644 --- a/web/routes/web.php +++ b/web/routes/web.php @@ -55,12 +55,21 @@ }); Route::get('/api/auth/callback', function (Request $request) { - $session = OAuth::callback( - $request->cookie(), - $request->query(), - ['App\Lib\CookieHandler', 'saveShopifyCookie'], - ); - + try { + $cookies = $request->cookie(); + if ($request->cookie() == null) { + $cookies = $_COOKIE; + } + $session = OAuth::callback( + $cookies, + $request->query(), + ['App\Lib\CookieHandler', 'saveShopifyCookie'], + ); + } catch (Exception $e) { + Log::warning('Failed to authenticate: ' . $e->getMessage()); + return redirect('/api/auth?shop=' . $request->query('shop')); + } + $host = $request->query('host'); $shop = Utils::sanitizeShopDomain($request->query('shop'));