mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-03 11:09:27 +00:00
1. 添加RBAC的权限&角色控制件; 2. 将用户‘is_admin’转换为角色; 3. 针对RBAC对管理页面进行定制化处理; 4. 加深layout分层处理; 5. 修改部分路由名称; 6. 分解路由文件至多文件;
32 lines
725 B
PHP
32 lines
725 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Spatie\Permission\Exceptions\UnauthorizedException;
|
|
|
|
class Permission
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param Request $request
|
|
* @param Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next, $guard = null)
|
|
{
|
|
if (app('auth')->guard($guard)->guest()) {
|
|
throw UnauthorizedException::notLoggedIn();
|
|
}
|
|
|
|
$route = request()->route()->getName();
|
|
if (app('auth')->guard($guard)->user()->can($route)) {
|
|
return $next($request);
|
|
}
|
|
|
|
throw UnauthorizedException::forPermissions((array) $route);
|
|
}
|
|
}
|