Skip to content

Commit 865db72

Browse files
committed
fixed refresh token failed when token expired
1 parent b5fb6c0 commit 865db72

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@
3636
"ext-swoole": ">=4.5",
3737
"ext-json": "*",
3838
"ext-openssl": "*",
39-
"hyperf/cache": "^2.0",
40-
"hyperf/command": "^2.0",
41-
"hyperf/config": "^2.0",
42-
"hyperf/di": "^2.0",
43-
"hyperf/framework": "^2.0",
39+
"hyperf/cache": "~2.0.0",
40+
"hyperf/command": "~2.0.0",
41+
"hyperf/config": "~2.0.0",
42+
"hyperf/di": "~2.0.0",
43+
"hyperf/framework": "~2.0.0",
4444
"lcobucci/jwt": "~3.3.0",
4545
"nesbot/carbon": "^2.0"
4646
},
4747
"require-dev": {
4848
"friendsofphp/php-cs-fixer": "^2.14",
49-
"hyperf/testing": "^2.0",
49+
"hyperf/testing": "~2.0.0",
5050
"phpstan/phpstan": "^0.12",
5151
"swoole/ide-helper": "dev-master",
5252
"mockery/mockery": "^1.0"

src/Jwt.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function refresh(bool $forceForever = false): string
106106
return $this->token = $this->manager
107107
->refresh($this->token, $forceForever, array_merge(
108108
$this->getCustomClaims(),
109-
($prv = $this->getPayload()->get('prv')) ? ['prv' => $prv] : []
109+
($prv = $this->getPayload(true)->get('prv')) ? ['prv' => $prv] : []
110110
))
111111
->get();
112112
}
@@ -172,7 +172,7 @@ public function getToken(): ?Token
172172
/**
173173
* Parse the token from the request.
174174
*
175-
*@throws \HyperfExt\Jwt\Exceptions\JwtException
175+
* @throws \HyperfExt\Jwt\Exceptions\JwtException
176176
* @return $this
177177
*/
178178
public function parseToken()
@@ -188,11 +188,11 @@ public function parseToken()
188188
* Get the raw Payload instance.
189189
* @throws \HyperfExt\Jwt\Exceptions\JwtException
190190
*/
191-
public function getPayload(): Payload
191+
public function getPayload(bool $ignoreExpired = false): Payload
192192
{
193193
$this->requireToken();
194194

195-
return $this->manager->decode($this->token);
195+
return $this->manager->decode($this->token, true, $ignoreExpired);
196196
}
197197

198198
/**

0 commit comments

Comments
 (0)