Skip to content

Commit

Permalink
UserStorage: fixed if identity is null
Browse files Browse the repository at this point in the history
  • Loading branch information
MartkCz authored Oct 4, 2020
1 parent e145988 commit d7bc6f9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/UserStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ public function isAuthenticated(): bool {
}

public function getIdentity(): ?IIdentity {
if (!$this->identity) {
if ($this->identity === false) {
$identity = parent::getIdentity();

$account = $this->model->findById($identity->getId());
if (!$account) { // clear identity, account not found
$this->setAuthenticated(false);
$this->setIdentity(null);

if ($identity) {
$account = $this->model->findById($identity->getId());
if (!$account) { // clear identity, account not found
$this->setAuthenticated(false);
$this->setIdentity(null);
} else {
$this->identity = $this->identityFactory->create($identity->getId(), $account);
}
} else {
$this->identity = $this->identityFactory->create($identity->getId(), $account);
$this->identity = null;
}
}

Expand Down

0 comments on commit d7bc6f9

Please sign in to comment.