]> BookStack Code Mirror - bookstack/blob - app/Http/Middleware/CheckGuard.php
Updated translator & dependency attribution before release v25.05.1
[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      *
16      * @return mixed
17      */
18     public function handle($request, Closure $next, ...$allowedGuards)
19     {
20         $activeGuard = config('auth.method');
21         if (!in_array($activeGuard, $allowedGuards)) {
22             session()->flash('error', trans('errors.permission'));
23
24             return redirect('/');
25         }
26
27         return $next($request);
28     }
29 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.