Skip to content

Commit

Permalink
fixed refresh token failed when token expired
Browse files Browse the repository at this point in the history
  • Loading branch information
ericyzhu committed Dec 24, 2020
1 parent b5fb6c0 commit 865db72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@
"ext-swoole": ">=4.5",
"ext-json": "*",
"ext-openssl": "*",
"hyperf/cache": "^2.0",
"hyperf/command": "^2.0",
"hyperf/config": "^2.0",
"hyperf/di": "^2.0",
"hyperf/framework": "^2.0",
"hyperf/cache": "~2.0.0",
"hyperf/command": "~2.0.0",
"hyperf/config": "~2.0.0",
"hyperf/di": "~2.0.0",
"hyperf/framework": "~2.0.0",
"lcobucci/jwt": "~3.3.0",
"nesbot/carbon": "^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
"hyperf/testing": "^2.0",
"hyperf/testing": "~2.0.0",
"phpstan/phpstan": "^0.12",
"swoole/ide-helper": "dev-master",
"mockery/mockery": "^1.0"
Expand Down
8 changes: 4 additions & 4 deletions src/Jwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function refresh(bool $forceForever = false): string
return $this->token = $this->manager
->refresh($this->token, $forceForever, array_merge(
$this->getCustomClaims(),
($prv = $this->getPayload()->get('prv')) ? ['prv' => $prv] : []
($prv = $this->getPayload(true)->get('prv')) ? ['prv' => $prv] : []
))
->get();
}
Expand Down Expand Up @@ -172,7 +172,7 @@ public function getToken(): ?Token
/**
* Parse the token from the request.
*
*@throws \HyperfExt\Jwt\Exceptions\JwtException
* @throws \HyperfExt\Jwt\Exceptions\JwtException
* @return $this
*/
public function parseToken()
Expand All @@ -188,11 +188,11 @@ public function parseToken()
* Get the raw Payload instance.
* @throws \HyperfExt\Jwt\Exceptions\JwtException
*/
public function getPayload(): Payload
public function getPayload(bool $ignoreExpired = false): Payload
{
$this->requireToken();

return $this->manager->decode($this->token);
return $this->manager->decode($this->token, true, $ignoreExpired);
}

/**
Expand Down

0 comments on commit 865db72

Please sign in to comment.