]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Middleware/Authenticate.php
Cleaned tests up, Started LDAP tests, Created LDAP wrapper
[bookstack] / app / Http / Middleware / Authenticate.php
index b09e9cd32519630837e2d98b0d537d19df653059..ad804d0d86b15e16fb6c2bb6a553d7f4b29401ab 100644 (file)
@@ -1,9 +1,11 @@
 <?php
 
-namespace Oxbow\Http\Middleware;
+namespace BookStack\Http\Middleware;
 
 use Closure;
 use Illuminate\Contracts\Auth\Guard;
+use BookStack\Exceptions\UserRegistrationException;
+use Setting;
 
 class Authenticate
 {
@@ -17,8 +19,7 @@ class Authenticate
     /**
      * Create a new filter instance.
      *
-     * @param  Guard  $auth
-     * @return void
+     * @param  Guard $auth
      */
     public function __construct(Guard $auth)
     {
@@ -34,11 +35,15 @@ class Authenticate
      */
     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');
             }
         }