btcloud/app/middleware/CheckAdmin.php

20 lines
430 B
PHP
Raw Permalink Normal View History

2022-06-04 11:22:19 -04:00
<?php
declare (strict_types=1);
namespace app\middleware;
class CheckAdmin
{
public function handle($request, \Closure $next)
{
if (!request()->islogin) {
if ($request->isAjax() || !$request->isGet()) {
return json(['code'=>-1, 'msg'=>'未登录'])->code(401);
}
return redirect((string)url('/admin/login'));
}
return $next($request);
}
}