diff --git a/extend/catcher/CatchAuth.php b/extend/catcher/CatchAuth.php index 9459113..60fce14 100644 --- a/extend/catcher/CatchAuth.php +++ b/extend/catcher/CatchAuth.php @@ -18,7 +18,7 @@ class CatchAuth protected $password = 'password'; // 保存用户信息 - protected $user = null; + protected $user = []; public function __construct() { @@ -69,23 +69,27 @@ class CatchAuth */ public function user() { - if (!$this->user) { + $user = $this->user[$this->guard] ?? null; + + if (!$user) { switch ($this->getDriver()) { case 'jwt': $model = app($this->getProvider()['model']); - $this->user = $model->where($model->getPk(), JWTAuth::auth()[$this->jwtKey()])->find(); + $user = $model->where($model->getPk(), JWTAuth::auth()[$this->jwtKey()])->find(); break; case 'session': - $this->user = Session::get($this->sessionUserKey(), null); + $user = Session::get($this->sessionUserKey(), null); break; default: throw new FailedException('user not found'); } - return $this->user; + $this->user[$this->guard] = $user; + + return $user; } - return $this->user; + return $user; } /** diff --git a/extend/catcher/command/TestCommand.php b/extend/catcher/command/TestCommand.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/extend/catcher/command/TestCommand.php @@ -0,0 +1 @@ +