3 namespace BookStack\Http\Middleware;
6 use Illuminate\Contracts\Auth\Guard;
7 use BookStack\Exceptions\UserRegistrationException;
13 * The Guard implementation.
19 * Create a new filter instance.
22 public function __construct(Guard $auth)
28 * Handle an incoming request.
29 * @param \Illuminate\Http\Request $request
30 * @param \Closure $next
33 public function handle($request, Closure $next)
35 if ($this->auth->check() && setting('registration-confirmation') && !$this->auth->user()->email_confirmed) {
36 return redirect(baseUrl('/register/confirm/awaiting'));
39 if ($this->auth->guest() && !setting('app-public')) {
40 if ($request->ajax()) {
41 return response('Unauthorized.', 401);
43 return redirect()->guest(baseUrl('/login'));
47 return $next($request);