Skip to content

Commit 9631d44

Browse files
committed
Track session usage when setting the token
1 parent 79f27fb commit 9631d44

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Authentication/Token/Storage/TokenStorage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public function setToken(TokenInterface $token = null)
4949
@trigger_error(sprintf('Not implementing the "%s::getRoleNames()" method in "%s" is deprecated since Symfony 4.3.', TokenInterface::class, \get_class($token)), E_USER_DEPRECATED);
5050
}
5151

52+
if ($token) {
53+
// ensure any initializer is called
54+
$this->getToken();
55+
}
56+
5257
$this->initializer = null;
5358
$this->token = $token;
5459
}

Authentication/Token/Storage/UsageTrackingTokenStorage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public function getToken(): ?TokenInterface
5252
public function setToken(TokenInterface $token = null): void
5353
{
5454
$this->storage->setToken($token);
55+
56+
if ($token && $this->enableUsageTracking) {
57+
// increments the internal session usage index
58+
$this->sessionLocator->get('session')->getMetadataBag();
59+
}
5560
}
5661

5762
public function enableUsageTracking(): void

0 commit comments

Comments
 (0)