You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
430 B

1 year ago
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\middleware;
  4. class CheckAdmin
  5. {
  6. public function handle($request, \Closure $next)
  7. {
  8. if (!request()->islogin) {
  9. if ($request->isAjax() || !$request->isGet()) {
  10. return json(['code'=>-1, 'msg'=>'未登录'])->code(401);
  11. }
  12. return redirect((string)url('/admin/login'));
  13. }
  14. return $next($request);
  15. }
  16. }