From 73a1c6a6e3839472bc088161dfb3f010b45a3078 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sat, 4 Jun 2016 23:02:18 +0300 Subject: [PATCH] Fix for error in Authenticate.php --- app/Http/Middleware/Authenticate.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 1b38969fe929..e5135eeaa7fd 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -18,7 +18,7 @@ class Authenticate { public function handle($request, Closure $next, $guard = 'user') { $authenticated = Auth::guard($guard)->check(); - + if($guard=='client'){ if(!empty($request->invitation_key)){ $contact_key = session('contact_key'); @@ -33,7 +33,7 @@ class Authenticate { ]); } - if ($contact->id != $invitation->contact_id) { + if ($contact && $contact->id != $invitation->contact_id) { // This is a different client; reauthenticate $authenticated = false; Auth::guard($guard)->logout(); @@ -64,17 +64,17 @@ class Authenticate { // This is an admin; let them pretend to be a client $authenticated = true; } - + // Does this account require portal passwords? if($account && (!$account->enable_portal_password || !$account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD))){ $authenticated = true; } - + if(!$authenticated && $contact && !$contact->password){ $authenticated = true; } } - + if (!$authenticated) { if ($request->ajax()) @@ -89,7 +89,7 @@ class Authenticate { return $next($request); } - + protected function getInvitation($key){ $invitation = Invitation::withTrashed()->where('invitation_key', '=', $key)->first(); if ($invitation && !$invitation->is_deleted) {