Skip to content

Commit

Permalink
fix: 权限不足异常处理
Browse files Browse the repository at this point in the history
  • Loading branch information
leeqvip committed Feb 18, 2023
1 parent 812176d commit db98188
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/middleware/PermissionCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

use tadmin\controller\Transfer;
use tadmin\service\auth\facade\Auth;
use tadmin\support\controller\Controller;
use tauthz\facade\Enforcer;
use think\App;

class PermissionCheck
class PermissionCheck extends Controller
{
protected $app;

protected $request;

public function __construct(App $app)
{
$this->app = $app;
parent::__construct($app);
}

public function handle($request, \Closure $next)
Expand All @@ -33,8 +34,7 @@ public function handle($request, \Closure $next)
$enforcer = $this->app->get('tadmin.enforcer');

if (true !== $enforcer->enforce('adminer.' . $adminer->id, $this->request->method(true), $this->parseCurrentPath())) {
return controller(Transfer::class, '')->message('权限不足');
// throw new \Exception('权限不足');
return $this->error("权限不足");
}

return $next($request);
Expand Down

0 comments on commit db98188

Please sign in to comment.