fix(common): getEncryptedToken 的 php8 兼容修复

(cherry picked from commit 198604c584)
pull/460/head
F4nniu 2024-02-11 21:46:44 +08:00
parent 2e4fe16f44
commit b0a3851d93
2 changed files with 2 additions and 0 deletions

View File

@ -76,6 +76,7 @@ abstract class Driver
protected function getEncryptedToken($token) protected function getEncryptedToken($token)
{ {
$config = \think\Config::get('token'); $config = \think\Config::get('token');
$token = $token ?? ''; // 为兼容 php8
return hash_hmac($config['hashalgo'], $token, $config['key']); return hash_hmac($config['hashalgo'], $token, $config['key']);
} }

View File

@ -60,6 +60,7 @@ class Redis extends Driver
protected function getEncryptedToken($token) protected function getEncryptedToken($token)
{ {
$config = \think\Config::get('token'); $config = \think\Config::get('token');
$token = $token ?? ''; // 为兼容 php8
return $this->options['tokenprefix'] . hash_hmac($config['hashalgo'], $token, $config['key']); return $this->options['tokenprefix'] . hash_hmac($config['hashalgo'], $token, $config['key']);
} }