更新
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user