mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 14:09:43 -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,19 +14,22 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->view('layouts/basic', [
|
return response()->view('layouts/basic', [
|
||||||
'content' => view('errors/403')
|
'content' => view('errors/403')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue