vendor/zely/security-bundle/src/TokenHandler.php line 19
<?php
namespace Zely\Security;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Http\AccessToken\AccessTokenHandlerInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
class TokenHandler implements AccessTokenHandlerInterface
{
public function getUserBadgeFrom(string $accessToken): UserBadge
{
if (!$accessToken) {
throw new BadCredentialsException('Invalid credentials.');
}
$parts = explode("||", $accessToken);
$tActor = $parts[1];
// and return a UserBadge object containing the user identifier from the found token
return new UserBadge($tActor, function ($id) use ($parts) {
$tEmail = $parts[2];
$tRoles = explode(",",$parts[3]);
$tRoles = array_filter($tRoles, function ($r) {
return $r;
});
return (new User($id, $tRoles, true))
->setEmail($tEmail);
});
}
}