From cafd6152ef899ec01aed5d0bb469278d9a016eff Mon Sep 17 00:00:00 2001 From: mychidarko Date: Tue, 12 Nov 2024 14:19:44 +0000 Subject: [PATCH] fix: catch jwt decode errors --- src/Auth.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Auth.php b/src/Auth.php index 7b1b92a..0df9b72 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -485,10 +485,15 @@ public function parseToken() return null; } - return (array) JWT::decode( - $bearerToken, - new Key(Config::get('token.secret'), 'HS256') - ); + try { + return (array) JWT::decode( + $bearerToken, + new Key(Config::get('token.secret'), 'HS256') + ); + } catch (\Throwable $th) { + $this->errorsArray['token'] = $th->getMessage(); + return null; + } } /**