24 lines
552 B
PHP
24 lines
552 B
PHP
<?php
|
|
|
|
namespace app\middleware;
|
|
|
|
use app\service\AdminScopeService;
|
|
use think\exception\HttpResponseException;
|
|
|
|
class AdminAuth
|
|
{
|
|
public function handle($request, \Closure $next)
|
|
{
|
|
$user = $request->authUser ?? null;
|
|
if (!$user || !AdminScopeService::canAccessAdmin($user)) {
|
|
throw new HttpResponseException(json([
|
|
'code' => 1,
|
|
'message' => '无管理后台访问权限',
|
|
'data' => null,
|
|
], 403));
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|