- Fixed deleted users which tries to login/refresh - triggers a logout().

- Password is now optional, allowing easier hi-jacking of the login process, like through an OAuth or LDAP.
This commit is contained in:
Dave M. 2021-03-01 16:11:22 +00:00
parent c38f47d9a7
commit 55a7af6ac9
1 changed files with 4 additions and 2 deletions

View File

@ -37,6 +37,8 @@ class Authenticate {
{ {
$logUser = function(int $id) use ($repository) { $logUser = function(int $id) use ($repository) {
if ( null === ( $user = $repository->loadFromPk($id) ) ) { if ( null === ( $user = $repository->loadFromPk($id) ) ) {
$this->logout();
throw new \Exception("User not found."); throw new \Exception("User not found.");
} }
@ -61,7 +63,7 @@ class Authenticate {
$this->session->destroy(); $this->session->destroy();
} }
public function authenticate(\Ulmus\Repository $repository, array $userLogin, string $password) : User public function authenticate(\Ulmus\Repository $repository, array $userLogin, ? string $password) : User
{ {
foreach($userLogin as $field => $value) { foreach($userLogin as $field => $value) {
$repository->or($field, $value); $repository->or($field, $value);
@ -111,7 +113,7 @@ class Authenticate {
$this->cookie->delete('user.id'); $this->cookie->delete('user.id');
} }
$this->user->logged = false; $this->user && $this->user->logged = false;
return $this; return $this;
} }