This commit is contained in:
2026-08-05 14:05:08 +08:00
parent 9ffc9687d0
commit e831ce810b
8 changed files with 39 additions and 37 deletions

View File

@@ -2,9 +2,12 @@
declare (strict_types = 1);
namespace app\middleware;
use app\common\Trait\ApiResponse;
use think\facade\Session;
class CheckLogin
{
use ApiResponse;
/**
* 处理请求
* @param \think\Request $request
@@ -14,7 +17,7 @@ class CheckLogin
public function handle($request, \Closure $next)
{
if (!Session::has('user_info')) {
return json(['code' => 401, 'message' => '未登录']);
return $this->error('未登录', [], 401);
}
return $next($request);
}