<?php
-namespace Oxbow\Http\Middleware;
+namespace BookStack\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
+use BookStack\Exceptions\UserRegistrationException;
+use Setting;
class Authenticate
{
/**
* Create a new filter instance.
*
- * @param Guard $auth
- * @return void
+ * @param Guard $auth
*/
public function __construct(Guard $auth)
{
*/
public function handle($request, Closure $next)
{
- if ($this->auth->guest()) {
+ if(auth()->check() && auth()->user()->email_confirmed == false) {
+ return redirect()->guest('/register/confirm/awaiting');
+ }
+
+ if ($this->auth->guest() && !Setting::get('app-public')) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
- return redirect()->guest('auth/login');
+ return redirect()->guest('/login');
}
}