更新解析token解析

This commit is contained in:
yaooo 2023-11-13 10:36:33 +08:00
parent 2c7dcd6fe1
commit a2d10ead95
2 changed files with 3 additions and 2 deletions

View File

@ -14,6 +14,7 @@
return [ return [
'middleware' => [ 'middleware' => [
app\api\http\middleware\InitMiddleware::class, // 初始化 app\api\http\middleware\InitMiddleware::class, // 初始化
app\api\http\middleware\LoginMiddleware::class, // 登录验证 // app\api\http\middleware\LoginMiddleware::class, // 登录验证
app\api\http\middleware\LoginJwtMiddleware::class, // jwt验证
], ],
]; ];

View File

@ -40,7 +40,7 @@ class LoginMiddleware
//不直接判断$isNotNeedLogin结果使不需要登录的接口通过为了兼容某些接口可以登录或不登录访问 //不直接判断$isNotNeedLogin结果使不需要登录的接口通过为了兼容某些接口可以登录或不登录访问
if (empty($token) && !$isNotNeedLogin) { if (empty($token) && !$isNotNeedLogin) {
//没有token并且该地址需要登录才能访问, 指定show为0前端不弹出此报错 //没有token并且该地址需要登录才能访问, 指定show为0前端不弹出此报错
return JsonService::fail('请求参数缺token', [], 0, 0); return JsonService::fail('请求参数缺token', [], 0, 0);
} }
$userInfo = (new UserTokenCache())->getUserInfo($token); $userInfo = (new UserTokenCache())->getUserInfo($token);