From fa043416086a303e563c237a5ed7e325f115d567 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Sat, 23 May 2020 11:10:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20auth=20=E5=8D=95=E4=BE=8B?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=A4=9A=E6=AC=A1=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/cms/controller/Test.php | 13 +++++++++++++ extend/catcher/CatchAuth.php | 27 +++++++++++++++++++-------- 2 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 catch/cms/controller/Test.php 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; } /**