Skip to content

Commit 0d95c40

Browse files
committed
优化自动获取
1 parent 241b8b1 commit 0d95c40

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

src/Handle/RequestToken.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,23 @@ public function __construct(App $app)
3030
public function get($handle): string
3131
{
3232
if (is_string($handle)) {
33-
if (!in_array($handle, $this->handles)) {
34-
throw new JwtException('不支持此方式获取.', 500);
35-
}
36-
} else if (is_array($handle) && !empty($handle)) {
37-
$handles = $handle;
38-
foreach($handles as $item) {
39-
if (in_array($item, $this->handles)) {
40-
$handle = $item;
41-
continue;
33+
$handles = explode('|', $handle);
34+
}
35+
36+
foreach ($handles as $handle) {
37+
if (in_array($handle, $this->handles)) {
38+
$namespace = '\\xiaodi\\JWTAuth\Handle\\' . $handle;
39+
$token = (new $namespace($this->app))->handle();
40+
if ($token) {
41+
$this->token = $token;
42+
break;
4243
}
44+
continue;
45+
} else {
46+
throw new JwtException('不支持此方式获取.', 500);
4347
}
4448
}
4549

46-
$namespace = '\\xiaodi\\JWTAuth\Handle\\' . $handle;
47-
$this->token = (new $namespace($this->app))->handle();
48-
4950
if (!$this->token) {
5051
throw new JwtException('获取Token失败.', 500);
5152
}

0 commit comments

Comments
 (0)