This commit is contained in:
2021-07-08 19:16:27 +08:00
parent 516c7612a5
commit 30b430f1cf
+18 -2
View File
@@ -5,11 +5,11 @@ namespace Snowflake\Jwt;
use Exception; use Exception;
use HttpServer\Http\HttpHeaders; use HttpServer\Http\HttpHeaders;
use Snowflake\Cache\Redis; use Snowflake\Abstracts\Component;
use Snowflake\Abstracts\Config; use Snowflake\Abstracts\Config;
use Snowflake\Cache\Redis;
use Snowflake\Core\Str; use Snowflake\Core\Str;
use Snowflake\Exception\AuthException; use Snowflake\Exception\AuthException;
use Snowflake\Abstracts\Component;
use Snowflake\Exception\ConfigException; use Snowflake\Exception\ConfigException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
@@ -222,6 +222,22 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY=
return $this->create($this->user, $headers); return $this->create($this->user, $headers);
} }
/**
* @param array $headers
* @return mixed
* @throws AuthException
*/
public function getTokenUser(array $headers = []): int
{
$this->data = $headers;
if (!openssl_public_decrypt(base64_decode($headers['refresh']), $data, $this->public)) {
throw new AuthException('信息解码失败.');
}
return (int)$data['user'];
}
/** /**
* @param array $param * @param array $param
* *