- Some minor fixes to match the EntityTrait relation loading

This commit is contained in:
Dave M. 2020-12-07 17:29:11 +00:00
parent d7010b6c3b
commit 9508fb79f9
1 changed files with 3 additions and 4 deletions

View File

@ -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 ]);
}