Skip to content

Commit f3f47ad

Browse files
Spomkyvincentchalamon
authored andcommitted
Update docs for 6.2.0-RC1 changes to TokenHandlerInterface
Co-authored-by: Vincent <vincentchalamon@protonmail.com>
1 parent b65c136 commit f3f47ad

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

security/access_token.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ This handler must implement
8282

8383
use App\Repository\AccessTokenRepository;
8484
use Symfony\Component\Security\Http\AccessToken\AccessTokenHandlerInterface;
85+
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
8586

8687
class AccessTokenHandler implements AccessTokenHandlerInterface
8788
{
@@ -90,16 +91,16 @@ This handler must implement
9091
) {
9192
}
9293

93-
public function getUserIdentifierFrom(string $token): string
94+
public function getUserBadgeFrom(string $accessToken): UserBadge
9495
{
9596
// e.g. query the "access token" database to search for this token
9697
$accessToken = $this->repository->findOneByValue($token);
97-
if ($accessToken === null || !$accessToken->isValid()) {
98+
if (null === $accessToken || !$accessToken->isValid()) {
9899
throw new BadCredentialsException('Invalid credentials.');
99100
}
100101

101-
// and return the user identifier from the found token
102-
return $accessToken->getUserId();
102+
// and return a UserBadge object containing the user identifier from the found token
103+
return new UserBadge($accessToken->getUserId());
103104
}
104105
}
105106

0 commit comments

Comments
 (0)