2020-02-02 21:10:21 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
|
|
|
|
class CheckGuard
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
2021-06-26 23:23:15 +08:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
* @param string $allowedGuards
|
|
|
|
*
|
2020-02-02 21:10:21 +08:00
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next, ...$allowedGuards)
|
|
|
|
{
|
|
|
|
$activeGuard = config('auth.method');
|
|
|
|
if (!in_array($activeGuard, $allowedGuards)) {
|
|
|
|
session()->flash('error', trans('errors.permission'));
|
2021-06-26 23:23:15 +08:00
|
|
|
|
2020-02-02 21:10:21 +08:00
|
|
|
return redirect('/');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|