X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/0b364fd72f994e6dff572a1606f3aa26e7690aa1..42d8e9e5bda57a26bbaa3f6e4a9e4e5f94a341e7:/app/Http/Controllers/Controller.php diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 26eeb3002..43292d941 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -30,17 +30,22 @@ abstract class Controller extends BaseController */ public function __construct() { - // Get a user instance for the current user - $user = auth()->user(); - if (!$user) $user = User::getDefault(); + $this->middleware(function ($request, $next) { - // Share variables with views - view()->share('signedIn', auth()->check()); - view()->share('currentUser', $user); + // Get a user instance for the current user + $user = auth()->user(); + if (!$user) $user = User::getDefault(); - // Share variables with controllers - $this->currentUser = $user; - $this->signedIn = auth()->check(); + // Share variables with views + view()->share('signedIn', auth()->check()); + view()->share('currentUser', $user); + + // Share variables with controllers + $this->currentUser = $user; + $this->signedIn = auth()->check(); + + return $next($request); + }); } /**