123456789101112131415161718192021222324252627282930 |
- <?php
- declare (strict_types = 1);
- namespace app\middleware;
- use think\Response;
- class CheckJwtToken
- {
- /**
- * 处理请求
- *
- * @param \think\Request $request
- * @param \Closure $next
- * @return Response
- */
- public function handle($request, \Closure $next)
- {
- $token = $request->header('token') ?? '';
- if(! $token) {
- return json(['code' => 777 , 'msg' => '请求有误!' , 'data' => null]);
- }
- $data = checkToken($token);
- if (0 != $data['code']){
- return json($data);
- }
- return $next($request);
- }
- }
|