Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
edenleung committed Feb 27, 2021
1 parent 3e5d469 commit fa739f9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/Config/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ public function getAutomaticRenewal()
return $this->automatic_renewal;
}

public function getTokenType()
public function getType()
{
return $this->type;
}

}
6 changes: 3 additions & 3 deletions src/Facade/Jwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use think\Facade;

/**
* @see \xiaodi\JWTAuth\Jwt
* @mixin \xiaodi\JWTAuth\Jwt
* @see \xiaodi\JWTAuth\Service\Jwt
* @mixin \xiaodi\JWTAuth\Service\Jwt
*/
class Jwt extends Facade
{
Expand All @@ -19,6 +19,6 @@ class Jwt extends Facade
*/
protected static function getFacadeClass()
{
return \xiaodi\JWTAuth\JwtAuth::class;
return \xiaodi\JWTAuth\Service\JwtAuth::class;
}
}
11 changes: 11 additions & 0 deletions src/Service/JwtAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,15 @@ protected function wasBan($token)
throw new TokenAlreadyEexpired('token was ban', $config->getReloginCode());
}
}

public function logout(string $token = null)
{
$service = $this->app->get('jwt.token');
if (!$token) {
$token = $service->getRequestToken();
}

$token = $service->parse($token);
$this->app->get('jwt.manager')->pushBlacklist($token);
}
}
2 changes: 1 addition & 1 deletion src/Service/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function pushWhitelist(Token $token): void
$this->setCache($tag, $key, $token, $ttl);
}

protected function pushBlacklist(Token $token): void
public function pushBlacklist(Token $token): void
{
$jti = $token->claims()->get('jti');
$store = $token->claims()->get('store');
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function getRequestToken(): string
{
$requestToken = new RequestToken($this->app);

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

return $token;
}
Expand Down

0 comments on commit fa739f9

Please sign in to comment.