Skip to content

Commit

Permalink
fixup! updated lcobucci/jwt to version 4.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmannmartin committed Apr 12, 2022
1 parent 95c0ff6 commit 5de6486
Showing 1 changed file with 15 additions and 0 deletions.
Expand Up @@ -5,6 +5,7 @@
namespace Shopsys\FrontendApiBundle\Model\Mutation\Login;

use GraphQL\Error\UserError;
use Lcobucci\JWT\Token\DataSet;
use Overblog\GraphQLBundle\Definition\Argument;
use Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface;
use Overblog\GraphQLBundle\Definition\Resolver\MutationInterface;
Expand Down Expand Up @@ -55,6 +56,8 @@ public function refreshTokens(Argument $argument): array
$refreshToken = $argument['input']['refreshToken'];
$token = $this->tokenFacade->getTokenByString($refreshToken);

$this->assertClaimsExists($token->claims());

$userUuid = $token->claims()->get('uuid');

try {
Expand All @@ -64,6 +67,7 @@ public function refreshTokens(Argument $argument): array
}

$tokenSecretChain = $token->claims()->get('secretChain');

$customerUserValidRefreshTokenChain = $this->customerUserRefreshTokenChainFacade->findCustomersTokenChainByCustomerUserAndSecretChain(
$customerUser,
$tokenSecretChain
Expand All @@ -85,6 +89,17 @@ public function refreshTokens(Argument $argument): array
];
}

/**
* @param \Lcobucci\JWT\Token\DataSet $claims
* @return void
*/
private function assertClaimsExists(DataSet $claims): void
{
if (!$claims->has('uuid') || !$claims->has('secretChain')) {
throw new UserError('Token is not valid.');
}
}

/**
* @return string[]
*/
Expand Down

0 comments on commit 5de6486

Please sign in to comment.