From b0a3851d934a8cfcd1f5bd662a4fe8759f2eb9a4 Mon Sep 17 00:00:00 2001 From: F4nniu Date: Sun, 11 Feb 2024 21:46:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(common):=20getEncryptedToken=20=E7=9A=84=20?= =?UTF-8?q?php8=20=E5=85=BC=E5=AE=B9=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 198604c584ed098ad6ac7d8bcfb888bcec92585c) --- application/common/library/token/Driver.php | 1 + application/common/library/token/driver/Redis.php | 1 + 2 files changed, 2 insertions(+) diff --git a/application/common/library/token/Driver.php b/application/common/library/token/Driver.php index 03463024..4d53b6b4 100644 --- a/application/common/library/token/Driver.php +++ b/application/common/library/token/Driver.php @@ -76,6 +76,7 @@ abstract class Driver protected function getEncryptedToken($token) { $config = \think\Config::get('token'); + $token = $token ?? ''; // 为兼容 php8 return hash_hmac($config['hashalgo'], $token, $config['key']); } diff --git a/application/common/library/token/driver/Redis.php b/application/common/library/token/driver/Redis.php index 0aa0caaa..ecf27502 100644 --- a/application/common/library/token/driver/Redis.php +++ b/application/common/library/token/driver/Redis.php @@ -60,6 +60,7 @@ class Redis extends Driver protected function getEncryptedToken($token) { $config = \think\Config::get('token'); + $token = $token ?? ''; // 为兼容 php8 return $this->options['tokenprefix'] . hash_hmac($config['hashalgo'], $token, $config['key']); }