diff options
-rw-r--r-- | app/Core/Security/AuthenticationManager.php | 2 | ||||
-rw-r--r-- | app/Core/Session/SessionStorage.php | 15 | ||||
-rw-r--r-- | tests/units/Core/Session/SessionStorageTest.php | 22 |
3 files changed, 38 insertions, 1 deletions
diff --git a/app/Core/Security/AuthenticationManager.php b/app/Core/Security/AuthenticationManager.php index dbc41b09..8e5f76be 100644 --- a/app/Core/Security/AuthenticationManager.php +++ b/app/Core/Security/AuthenticationManager.php @@ -71,7 +71,7 @@ class AuthenticationManager extends Base if ($this->userSession->isLogged() ) { foreach ($this->filterProviders('SessionCheckProviderInterface') as $provider) { if (! $provider->isValidSession()) { - unset($this->sessionStorage->user); + $this->sessionStorage->flush(); $this->preAuthentication(); return false; } diff --git a/app/Core/Session/SessionStorage.php b/app/Core/Session/SessionStorage.php index 11230793..f55a7ee3 100644 --- a/app/Core/Session/SessionStorage.php +++ b/app/Core/Session/SessionStorage.php @@ -62,6 +62,21 @@ class SessionStorage } /** + * Flush session data + * + * @access public + */ + public function flush() + { + $session = get_object_vars($this); + unset($session['storage']); + + foreach (array_keys($session) as $property) { + unset($this->$property); + } + } + + /** * Copy class properties to external storage * * @access public diff --git a/tests/units/Core/Session/SessionStorageTest.php b/tests/units/Core/Session/SessionStorageTest.php index 62495e5e..dd0040d5 100644 --- a/tests/units/Core/Session/SessionStorageTest.php +++ b/tests/units/Core/Session/SessionStorageTest.php @@ -35,4 +35,26 @@ class SessionStorageTest extends Base $storage = null; $this->assertEquals(array('something' => array('a' => 'c'), 'd' => 'e'), $session); } + + public function testFlush() + { + $session = array('d' => 'e'); + + $storage = new SessionStorage(); + $storage->setStorage($session); + $storage->something = array('a' => 'b'); + + $this->assertEquals(array('a' => 'b'), $storage->something); + $this->assertEquals('e', $storage->d); + + $storage->flush(); + + $this->assertFalse(isset($storage->d)); + $this->assertFalse(isset($storage->something)); + + $storage->foo = 'bar'; + + $storage = null; + $this->assertEquals(array('foo' => 'bar'), $session); + } } |