Commit 8c8a49b5 authored by 谢宇轩's avatar 谢宇轩 😅

Merge branch '1.1' into 'master'

1.1

See merge request back-end/easy-http-sdk!13
parents d2faec26 659c7772
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
], ],
"require": { "require": {
"php": ">7.2.5", "php": ">7.2.5",
"psr/log": "^1.1", "psr/log": "2.0",
"twig/twig": "^3.0", "twig/twig": "^3.0",
"symfony/cache": "^5.4", "symfony/cache": "^5.4",
"yosymfony/toml": "^1.0", "yosymfony/toml": "^1.0",
......
...@@ -29,9 +29,6 @@ class Application implements ClientInterface ...@@ -29,9 +29,6 @@ class Application implements ClientInterface
private const TOKEN_CACHE_KEY = "Auth.%s"; private const TOKEN_CACHE_KEY = "Auth.%s";
/** @var string jwtToken */
private $jwtToken = "";
/** @var Option $option */ /** @var Option $option */
private $option; private $option;
...@@ -158,9 +155,10 @@ class Application implements ClientInterface ...@@ -158,9 +155,10 @@ class Application implements ClientInterface
$stack->push($middleware); $stack->push($middleware);
} }
if ($request->authorization()) { if ($request->authorization()) {
if ($this->jwtToken === "") {
try { try {
$this->jwtToken = $this->getAccessTokenFromCache(); $jwtToken = $this->getAccessTokenFromCache();
$authMiddleware = $this->option->getAuthorizationMiddleware();
$stack->push(new $authMiddleware($jwtToken));
} catch (CacheInvalidArgumentException $exception) { } catch (CacheInvalidArgumentException $exception) {
// 缓存异常 // 缓存异常
throw new ApplicationException("auth cache error " . $exception->getMessage()); throw new ApplicationException("auth cache error " . $exception->getMessage());
...@@ -178,9 +176,6 @@ class Application implements ClientInterface ...@@ -178,9 +176,6 @@ class Application implements ClientInterface
throw new ApplicationException($exception->getMessage(), $request, [], $exception); throw new ApplicationException($exception->getMessage(), $request, [], $exception);
} }
} }
$authMiddleware = $this->option->getAuthorizationMiddleware();
$stack->push(new $authMiddleware($this->jwtToken));
}
} }
$options = [ $options = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment