Skip to content

Commit fa739f9

Browse files
committed
update
1 parent 3e5d469 commit fa739f9

5 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/Config/Token.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ public function getAutomaticRenewal()
8484
return $this->automatic_renewal;
8585
}
8686

87-
public function getTokenType()
87+
public function getType()
8888
{
8989
return $this->type;
9090
}
91-
9291
}

src/Facade/Jwt.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use think\Facade;
88

99
/**
10-
* @see \xiaodi\JWTAuth\Jwt
11-
* @mixin \xiaodi\JWTAuth\Jwt
10+
* @see \xiaodi\JWTAuth\Service\Jwt
11+
* @mixin \xiaodi\JWTAuth\Service\Jwt
1212
*/
1313
class Jwt extends Facade
1414
{
@@ -19,6 +19,6 @@ class Jwt extends Facade
1919
*/
2020
protected static function getFacadeClass()
2121
{
22-
return \xiaodi\JWTAuth\JwtAuth::class;
22+
return \xiaodi\JWTAuth\Service\JwtAuth::class;
2323
}
2424
}

src/Service/JwtAuth.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,15 @@ protected function wasBan($token)
111111
throw new TokenAlreadyEexpired('token was ban', $config->getReloginCode());
112112
}
113113
}
114+
115+
public function logout(string $token = null)
116+
{
117+
$service = $this->app->get('jwt.token');
118+
if (!$token) {
119+
$token = $service->getRequestToken();
120+
}
121+
122+
$token = $service->parse($token);
123+
$this->app->get('jwt.manager')->pushBlacklist($token);
124+
}
114125
}

src/Service/Manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function pushWhitelist(Token $token): void
7575
$this->setCache($tag, $key, $token, $ttl);
7676
}
7777

78-
protected function pushBlacklist(Token $token): void
78+
public function pushBlacklist(Token $token): void
7979
{
8080
$jti = $token->claims()->get('jti');
8181
$store = $token->claims()->get('store');

src/Service/Token.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function getRequestToken(): string
163163
{
164164
$requestToken = new RequestToken($this->app);
165165

166-
$token = $requestToken->get($this->config->getTokenType());
166+
$token = $requestToken->get($this->config->getType());
167167

168168
return $token;
169169
}

0 commit comments

Comments
 (0)