mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-04 23:13:41 +08:00
e6c6de0848
- Included tests to cover for LDAP and SAML - Updated wording for external auth id option. - Updated 'assertPermissionError' test case to be usable in BrowserKitTests
29 lines
655 B
PHP
29 lines
655 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);
|
|
}
|
|
}
|