Skip to content

Commit 817ee98

Browse files
committed
User::logout() steps reorder
1 parent 6ce3aab commit 817ee98

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/Security/User.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,7 @@ public function login($user, string $password = null): void
129129
*/
130130
final public function logout(bool $clearIdentity = false): void
131131
{
132-
if ($this->isLoggedIn()) {
133-
Arrays::invoke($this->onLoggedOut, $this);
134-
}
135-
136-
$this->authenticated = false;
137-
$this->identity = $clearIdentity ? null : $this->identity;
132+
$logged = $this->isLoggedIn();
138133

139134
if ($this->storage instanceof UserStorage) {
140135
$this->storage->clearAuthentication($clearIdentity);
@@ -143,8 +138,14 @@ final public function logout(bool $clearIdentity = false): void
143138
if ($clearIdentity) {
144139
$this->storage->setIdentity(null);
145140
}
146-
$this->logoutReason = self::MANUAL;
147141
}
142+
143+
$this->authenticated = false;
144+
$this->logoutReason = self::MANUAL;
145+
if ($logged) {
146+
Arrays::invoke($this->onLoggedOut, $this);
147+
}
148+
$this->identity = $clearIdentity ? null : $this->identity;
148149
}
149150

150151

0 commit comments

Comments
 (0)