snipe-it/app/Http/Middleware/CheckPermissions.php

32 lines
712 B
PHP
Raw Normal View History

2016-03-25 01:18:05 -07:00
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Gate;
2016-06-15 21:18:40 -07:00
2016-03-25 01:18:05 -07:00
class CheckPermissions
{
/**
* Handle the ACLs for permissions.
*
* The $section variable is passed via the route middleware,
* 'middleware' => [authorize:superadmin']
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $section
* @return mixed
*/
2016-06-02 02:48:52 -07:00
public function handle($request, Closure $next, $section = null)
2016-03-25 01:18:05 -07:00
{
2016-06-02 02:48:52 -07:00
if (Gate::allows($section)) {
2016-03-25 01:18:05 -07:00
return $next($request);
}
return response()->view('layouts/basic', [
'content' => view('errors/403'),
2016-03-25 01:18:05 -07:00
]);
}
}