Fix for error in Authenticate.php

This commit is contained in:
Hillel Coren 2016-06-04 23:02:18 +03:00
parent 37a92fc853
commit 73a1c6a6e3

View File

@ -18,7 +18,7 @@ class Authenticate {
public function handle($request, Closure $next, $guard = 'user') public function handle($request, Closure $next, $guard = 'user')
{ {
$authenticated = Auth::guard($guard)->check(); $authenticated = Auth::guard($guard)->check();
if($guard=='client'){ if($guard=='client'){
if(!empty($request->invitation_key)){ if(!empty($request->invitation_key)){
$contact_key = session('contact_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 // This is a different client; reauthenticate
$authenticated = false; $authenticated = false;
Auth::guard($guard)->logout(); Auth::guard($guard)->logout();
@ -64,17 +64,17 @@ class Authenticate {
// This is an admin; let them pretend to be a client // This is an admin; let them pretend to be a client
$authenticated = true; $authenticated = true;
} }
// Does this account require portal passwords? // Does this account require portal passwords?
if($account && (!$account->enable_portal_password || !$account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD))){ if($account && (!$account->enable_portal_password || !$account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD))){
$authenticated = true; $authenticated = true;
} }
if(!$authenticated && $contact && !$contact->password){ if(!$authenticated && $contact && !$contact->password){
$authenticated = true; $authenticated = true;
} }
} }
if (!$authenticated) if (!$authenticated)
{ {
if ($request->ajax()) if ($request->ajax())
@ -89,7 +89,7 @@ class Authenticate {
return $next($request); return $next($request);
} }
protected function getInvitation($key){ protected function getInvitation($key){
$invitation = Invitation::withTrashed()->where('invitation_key', '=', $key)->first(); $invitation = Invitation::withTrashed()->where('invitation_key', '=', $key)->first();
if ($invitation && !$invitation->is_deleted) { if ($invitation && !$invitation->is_deleted) {