Skip to content

Commit

Permalink
User::logout() steps reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 18, 2021
1 parent 6ce3aab commit 817ee98
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Security/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,7 @@ public function login($user, string $password = null): void
*/
final public function logout(bool $clearIdentity = false): void
{
if ($this->isLoggedIn()) {
Arrays::invoke($this->onLoggedOut, $this);
}

$this->authenticated = false;
$this->identity = $clearIdentity ? null : $this->identity;
$logged = $this->isLoggedIn();

if ($this->storage instanceof UserStorage) {
$this->storage->clearAuthentication($clearIdentity);
Expand All @@ -143,8 +138,14 @@ final public function logout(bool $clearIdentity = false): void
if ($clearIdentity) {
$this->storage->setIdentity(null);
}
$this->logoutReason = self::MANUAL;
}

$this->authenticated = false;
$this->logoutReason = self::MANUAL;
if ($logged) {
Arrays::invoke($this->onLoggedOut, $this);
}
$this->identity = $clearIdentity ? null : $this->identity;
}


Expand Down

0 comments on commit 817ee98

Please sign in to comment.