1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2024-10-30 23:52:40 +01:00
BookStack/app/Http/Middleware/PermissionMiddleware.php
2015-09-10 19:31:09 +01:00

29 lines
653 B
PHP

<?php
namespace BookStack\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Session;
class PermissionMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param $permission
* @return mixed
*/
public function handle($request, Closure $next, $permission)
{
if (!$request->user() || !$request->user()->can($permission)) {
Session::flash('error', trans('errors.permission'));
return redirect()->back();
}
return $next($request);
}
}