]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Middleware/Authenticate.php
Update all.blade.php
[bookstack] / app / Http / Middleware / Authenticate.php
index 599f40c84a7f61ccf9bf497d152dfb39726a0e81..c9b2726e8c4eca4f9148f7567a035433bf216879 100644 (file)
@@ -4,8 +4,6 @@ namespace BookStack\Http\Middleware;
 
 use Closure;
 use Illuminate\Contracts\Auth\Guard;
-use BookStack\Exceptions\UserRegistrationException;
-use Setting;
 
 class Authenticate
 {
@@ -32,15 +30,18 @@ class Authenticate
      */
     public function handle($request, Closure $next)
     {
-        if ($this->auth->check() && setting('registration-confirmation') && !$this->auth->user()->email_confirmed) {
-            return redirect()->guest('/register/confirm/awaiting');
+        if ($this->auth->check()) {
+            $requireConfirmation = (setting('registration-confirmation') || setting('registration-restrict'));
+            if ($requireConfirmation && !$this->auth->user()->email_confirmed) {
+                return redirect('/register/confirm/awaiting');
+            }
         }
 
         if ($this->auth->guest() && !setting('app-public')) {
             if ($request->ajax()) {
                 return response('Unauthorized.', 401);
             } else {
-                return redirect()->guest('/login');
+                return redirect()->guest(baseUrl('/login'));
             }
         }