mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
Switch to gate for permission check
This commit is contained in:
parent
dddb0f7267
commit
049e13e365
|
@ -5,6 +5,7 @@ namespace App\Http\Middleware;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Config;
|
use Config;
|
||||||
use Route;
|
use Route;
|
||||||
|
use Gate;
|
||||||
|
|
||||||
class CheckPermissions
|
class CheckPermissions
|
||||||
{
|
{
|
||||||
|
@ -13,13 +14,13 @@ class CheckPermissions
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Closure $next
|
* @param \Closure $next
|
||||||
* @param string|null $guard
|
* @param string|null $section
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next, $section = null, $guard = null)
|
public function handle($request, Closure $next, $section = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (($request->user()->hasAccess($section)) || ($request->user()->isSuperUser())) {
|
if (Gate::allows($section)) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,5 +28,8 @@ class CheckPermissions
|
||||||
'content' => view('errors/403')
|
'content' => view('errors/403')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue