From 817ee98aad1f122f8f40b728c35e634086e1093d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 12 Jan 2021 18:44:40 +0100 Subject: [PATCH] User::logout() steps reorder --- src/Security/User.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Security/User.php b/src/Security/User.php index 6f7ea9cb..77b68663 100644 --- a/src/Security/User.php +++ b/src/Security/User.php @@ -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); @@ -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; }