auth->guard('jwt')->user(); if (!$user) { return $this->response->json([ 'code' => 401, 'message' => '未授权,请先登录', ])->withStatus(401); } // @attention check here! // 检查用户状态 if (method_exists($user, '__get') && $user->status !== 1) { return $this->response->json([ 'code' => 403, 'message' => '账号已被禁用', ])->withStatus(403); } } catch (UnauthorizedException $e) { return $this->response->json([ 'code' => 401, 'message' => 'Token 无效或已过期', ])->withStatus(401); } catch (\Throwable $e) { return $this->response->json([ 'code' => 500, 'message' => '认证失败: ' . $e->getMessage(), ])->withStatus(500); } return $handler->handle($request); } }