From 7d9a9a62d2fdff7edd3299b3c1bbc7ce4a0412a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Escribano?= Date: Wed, 2 Oct 2024 13:38:02 +0200 Subject: [PATCH] feat: added a check if the OAuth information exists in the renew function of the OAuthController. --- src/Controllers/OAuthController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controllers/OAuthController.php b/src/Controllers/OAuthController.php index 8073543..3f8dd8c 100644 --- a/src/Controllers/OAuthController.php +++ b/src/Controllers/OAuthController.php @@ -133,10 +133,10 @@ public function renew(): null|\Illuminate\Routing\Redirector|RedirectResponse if (Auth::guard($guardName)->check()) { $user = Auth::guard($guardName)->user(); - $oauthData = OAuth::whereUserId($user?->getAuthIdentifier())->firstOrFail(); + $oauthData = OAuth::whereUserId($user?->getAuthIdentifier())->first(); // @phpstan-ignore-next-line - if ($oauthData->oauth_token !== null && $oauthData->oauth_token_expires_at < now()->timestamp) { + if ($oauthData !== null && $oauthData->oauth_token !== null && $oauthData->oauth_token_expires_at < now()->timestamp) { if (config('oauth.offline_access') === false) { return $this->unauthorizeAndLogout($oauthData, $guardName); }