Skip to content

Commit

Permalink
Make JWTManager::$userIdClaim nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
chalasr committed Nov 27, 2018
1 parent ba179c2 commit c1f857e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Services/JWTManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class JWTManager implements JWTManagerInterface, JWTTokenManagerInterface
/**
* @param JWTEncoderInterface $encoder
* @param EventDispatcherInterface $dispatcher
* @param string $userIdClaim
* @param string|null $userIdClaim
*/
public function __construct(JWTEncoderInterface $encoder, EventDispatcherInterface $dispatcher, $userIdClaim)
public function __construct(JWTEncoderInterface $encoder, EventDispatcherInterface $dispatcher, $userIdClaim = null)
{
$this->jwtEncoder = $encoder;
$this->dispatcher = $dispatcher;
Expand Down Expand Up @@ -107,7 +107,7 @@ public function decode(TokenInterface $token)
protected function addUserIdentityToPayload(UserInterface $user, array &$payload)
{
$accessor = PropertyAccess::createPropertyAccessor();
$payload[$this->userIdClaim] = $accessor->getValue($user, $this->userIdentityField);
$payload[$this->userIdClaim ?: $this->userIdentityField] = $accessor->getValue($user, $this->userIdentityField);
}

/**
Expand Down

0 comments on commit c1f857e

Please sign in to comment.