diff --git a/catch/cms/controller/Test.php b/catch/cms/controller/Test.php new file mode 100644 index 0000000..c7111b0 --- /dev/null +++ b/catch/cms/controller/Test.php @@ -0,0 +1,13 @@ +auth = config('catch.auth'); @@ -66,15 +69,23 @@ class CatchAuth */ public function user() { - switch ($this->getDriver()) { - case 'jwt': - $model = app($this->getProvider()['model']); - return $model->where($model->getPk(), JWTAuth::auth()[$this->jwtKey()])->find(); - case 'session': - return Session::get($this->sessionUserKey(), null); - default: - throw new FailedException('user not found'); + if (!$this->user) { + switch ($this->getDriver()) { + case 'jwt': + $model = app($this->getProvider()['model']); + $this->user = $model->where($model->getPk(), JWTAuth::auth()[$this->jwtKey()])->find(); + break; + case 'session': + $this->user = Session::get($this->sessionUserKey(), null); + break; + default: + throw new FailedException('user not found'); + } + + return $this->user; } + + return $this->user; } /**