Closed sym134 closed 1 year ago
use yzh52521\JwtAuth\facade\JwtAuth;
使用 yzh52521\JwtAuth\facade\JwtAuth;
新的报错: Creation of dynamic property yzh52521\JwtAuth\Jwt::$jwtConfiguration is deprecated
使用 yzh52521\JwtAuth\facade\JwtAuth;
新的报错: Creation of dynamic property yzh52521\JwtAuth\Jwt::$jwtConfiguration is deprecated
你参考一下 yzh52521\JwtAuth\middleware\JwtAuthMiddleware 这个中间件
我直接拷贝了这个中间价,依然是上面的报错,最后索性直接用这个JwtAuthMiddleware中间件还是一样的报错
你升级一下 再试试 我用的没问题
按照教程,但报错:Error: Non-static method yzh52521\JwtAuth\JwtAuth::getConfig() cannot be called statically in
代码如下:
`<?php
namespace app\api\middleware;
use Webman\Http\Request; use Webman\Http\Response; use Webman\MiddlewareInterface; use yzh52521\JwtAuth\exception\JwtException; use yzh52521\JwtAuth\JwtAuth; use yzh52521\JwtAuth\handle\RequestToken;
class Authenticate implements MiddlewareInterface { public function process(Request $request, callable $next): Response { if ($request->method() === 'OPTIONS') { response('', 204); } if ($route = $request->route) { $store = $route->param('store'); } $store = $store ?? (\request()->app === '' ? 'default' : \request()->app); try { $requestToken = new RequestToken(); $handel = JwtAuth::getConfig($store)->getType(); $token = $requestToken->get($handel); JwtAuth::verify($token); $request->user = JwtAuth::getUser(); return $next($request); } catch (JwtException $e) { return json(['message' => '请登录'], 401); } }
} `