From 9508fb79f9a68f5b931a16002c9a2be6f0564cf5 Mon Sep 17 00:00:00 2001 From: Dave M Date: Mon, 7 Dec 2020 17:29:11 +0000 Subject: [PATCH] - Some minor fixes to match the EntityTrait relation loading --- src/Lib/Authenticate.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Lib/Authenticate.php b/src/Lib/Authenticate.php index e86726f..2dc5641 100644 --- a/src/Lib/Authenticate.php +++ b/src/Lib/Authenticate.php @@ -68,7 +68,7 @@ class Authenticate { } try { - $this->user = $repository->loadOne(); + $this->user = $repository->loadOne() ?: $repository->instanciateEntity(); } catch(Exception\EmptyDatasetException $e) { call_user_func_array($this->authenticationEvent, [ false, 'userNotFound', $this->user ]); @@ -76,7 +76,7 @@ class Authenticate { return $repository->instanciateEntity(); } - if ( $this->user && $this->user->verifyPassword($password) ) { + if ( $this->user->isLoaded() && $this->user->verifyPassword($password) ) { $this->user->logged = true; if ( $this->session ) { @@ -90,9 +90,8 @@ class Authenticate { call_user_func_array($this->authenticationEvent, [ true, 'success', $this->user ]); } else { - $this->user = $repository->instanciateEntityCollection(); $this->user->logged = false; - + call_user_func_array($this->authenticationEvent, [ false, 'invalidPassword', $this->user ]); }