feat: 更新 README.md,添加 JwtToken.php 中缺失的授权信息异常处理说明

This commit is contained in:
lingling 2025-03-16 12:47:30 +08:00
parent 377efca3cb
commit c5b308c1c4
1 changed files with 4 additions and 1 deletions

View File

@ -42,12 +42,15 @@ NGINX配置
JwtToken.php 需要修改成如下
搜索 private static function getTokenFromHeaders(): string 定位路径
```
private static function getTokenFromHeaders(): string
private static function getTokenFromHeaders(): string
{
// $authorization = !empty(request()->header('authorization'))?request()->header('authorization'):request()->header('token');
$token1 = request()->header('Authorization');
$token2 =request()->header('Token');
$authorization_tmp = !empty($token1) ? $token1 : $token2;
if(empty($authorization_tmp)){
throw new JwtTokenException('请求未携带authorization信息');
}
// $authorization='Bearer '.$authorization_tmp;
if (strpos($authorization_tmp,"Bearer ") === false) {
$authorization= 'Bearer '.$authorization_tmp;