]> BookStack Code Mirror - bookstack/blob - app/Http/Middleware/CheckGuard.php
Translation error
[bookstack] / app / Http / Middleware / CheckGuard.php
1 <?php
2
3 namespace BookStack\Http\Middleware;
4
5 use Closure;
6
7 class CheckGuard
8 {
9     /**
10      * Handle an incoming request.
11      *
12      * @param  \Illuminate\Http\Request  $request
13      * @param  \Closure  $next
14      * @param string $allowedGuards
15      * @return mixed
16      */
17     public function handle($request, Closure $next, ...$allowedGuards)
18     {
19         $activeGuard = config('auth.method');
20         if (!in_array($activeGuard, $allowedGuards)) {
21             session()->flash('error', trans('errors.permission'));
22             return redirect('/');
23         }
24
25         return $next($request);
26     }
27 }