Skip to content

Commit 62c33d3

Browse files
committed
Resolve #828 - Site cache reset upon login
1 parent 8dc143d commit 62c33d3

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

app/sprinkles/account/src/Authenticate/Authenticator.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Birke\Rememberme\Storage\PDOStorage as RememberMePDO;
1212
use Birke\Rememberme\Triplet as RememberMeTriplet;
1313
use Illuminate\Database\Capsule\Manager as Capsule;
14-
use Interop\Container\ContainerInterface;
1514
use UserFrosting\Session\Session;
1615
use UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountDisabledException;
1716
use UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountInvalidException;
@@ -84,6 +83,7 @@ class Authenticator
8483
* @param ClassMapper $classMapper Maps generic class identifiers to specific class names.
8584
* @param Session $session The session wrapper object that will store the user's id.
8685
* @param Config $config Config object that contains authentication settings.
86+
* @param mixed $cache Cache service instance
8787
*/
8888
public function __construct(ClassMapper $classMapper, Session $session, $config, $cache)
8989
{
@@ -193,7 +193,7 @@ public function login($user, $rememberMe = false)
193193
$this->session->regenerateId(true);
194194

195195
// Since regenerateId deletes the old session, we'll do the same in cache
196-
$this->cache->tags([$this->config['cache.prefix'], '_s' . $oldId])->flush();
196+
$this->flushSessionCache($oldId);
197197

198198
// If the user wants to be remembered, create Rememberme cookie
199199
if ($rememberMe) {
@@ -251,7 +251,7 @@ public function logout($complete = false)
251251
$this->session->destroy();
252252

253253
// Since regenerateId deletes the old session, we'll do the same in cache
254-
$this->cache->tags([$this->config['cache.prefix'], '_s' . $oldId])->flush();
254+
$this->flushSessionCache($oldId);
255255

256256
// Restart the session service
257257
$this->session->start();
@@ -316,7 +316,7 @@ public function viaRemember()
316316
*/
317317
protected function loginRememberedUser()
318318
{
319-
/** @var Birke\Rememberme\LoginResult $loginResult */
319+
/** @var \Birke\Rememberme\LoginResult $loginResult */
320320
$loginResult = $this->rememberMe->login();
321321

322322
if ($loginResult->isSuccess()) {
@@ -405,4 +405,15 @@ protected function validateUserAccount($userId)
405405
return null;
406406
}
407407
}
408+
409+
/**
410+
* Flush the cache associated with a session id
411+
*
412+
* @param string $id The session id
413+
* @return bool
414+
*/
415+
public function flushSessionCache($id)
416+
{
417+
return $this->cache->tags('_s' . $id)->flush();
418+
}
408419
}

0 commit comments

Comments
 (0)