|
11 | 11 | use Birke\Rememberme\Storage\PDOStorage as RememberMePDO; |
12 | 12 | use Birke\Rememberme\Triplet as RememberMeTriplet; |
13 | 13 | use Illuminate\Database\Capsule\Manager as Capsule; |
14 | | -use Interop\Container\ContainerInterface; |
15 | 14 | use UserFrosting\Session\Session; |
16 | 15 | use UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountDisabledException; |
17 | 16 | use UserFrosting\Sprinkle\Account\Authenticate\Exception\AccountInvalidException; |
@@ -84,6 +83,7 @@ class Authenticator |
84 | 83 | * @param ClassMapper $classMapper Maps generic class identifiers to specific class names. |
85 | 84 | * @param Session $session The session wrapper object that will store the user's id. |
86 | 85 | * @param Config $config Config object that contains authentication settings. |
| 86 | + * @param mixed $cache Cache service instance |
87 | 87 | */ |
88 | 88 | public function __construct(ClassMapper $classMapper, Session $session, $config, $cache) |
89 | 89 | { |
@@ -193,7 +193,7 @@ public function login($user, $rememberMe = false) |
193 | 193 | $this->session->regenerateId(true); |
194 | 194 |
|
195 | 195 | // 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); |
197 | 197 |
|
198 | 198 | // If the user wants to be remembered, create Rememberme cookie |
199 | 199 | if ($rememberMe) { |
@@ -251,7 +251,7 @@ public function logout($complete = false) |
251 | 251 | $this->session->destroy(); |
252 | 252 |
|
253 | 253 | // 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); |
255 | 255 |
|
256 | 256 | // Restart the session service |
257 | 257 | $this->session->start(); |
@@ -316,7 +316,7 @@ public function viaRemember() |
316 | 316 | */ |
317 | 317 | protected function loginRememberedUser() |
318 | 318 | { |
319 | | - /** @var Birke\Rememberme\LoginResult $loginResult */ |
| 319 | + /** @var \Birke\Rememberme\LoginResult $loginResult */ |
320 | 320 | $loginResult = $this->rememberMe->login(); |
321 | 321 |
|
322 | 322 | if ($loginResult->isSuccess()) { |
@@ -405,4 +405,15 @@ protected function validateUserAccount($userId) |
405 | 405 | return null; |
406 | 406 | } |
407 | 407 | } |
| 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 | + } |
408 | 419 | } |
0 commit comments