app\middleware\JWTAuth::process(): Return value must be of type support\Response, Webman\Http\Response returned 已指明返回類型,仍是報錯
app\\middleware\\JWTAuth::process(): Return value must be of type support\\Response, Webman\\Http\\Response returned
中間件
中间内 那俩换成 use Webman\Http\Request; use Webman\Http\Response;
一个很简单的插件竟然被用的这么复杂
未解决,换了一种取值方式,不能直接userInfo取值了 $token = JwtToken::getExtend();
中间件正确使用方式
declare(strict_types=1); namespace app\middleware; use Tinywan\ExceptionHandler\Exception\ForbiddenHttpException; use Tinywan\Jwt\JwtToken; use Webman\Http\Request; use Webman\Http\Response; use Webman\MiddlewareInterface; class AuthorizationMiddleware implements MiddlewareInterface { /** * @param Request $request * @param callable $handler * @return Response * @throws ForbiddenHttpException */ public function process(Request $request, callable $handler): Response { $request->userId = JwtToken::getCurrentId(); if (0 === $request->userId) { throw new ForbiddenHttpException(); } return $handler($request); } }
中间内 那俩换成
use Webman\Http\Request;
use Webman\Http\Response;
一个很简单的插件竟然被用的这么复杂
未解决,换了一种取值方式,不能直接userInfo取值了
$token = JwtToken::getExtend();