From 8bf7380d822ba2ba9c834afa662741bc7c17367d Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Sat, 23 May 2020 14:04:23 +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=E6=94=AF=E6=8C=81?= =?UTF-8?q?=20guard=20=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchAuth.php | 16 ++++++++++------ extend/catcher/command/TestCommand.php | 1 + extend/catcher/library/excel/Excel.php | 1 + extend/catcher/library/excel/ExcelContract.php | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 extend/catcher/command/TestCommand.php create mode 100644 extend/catcher/library/excel/Excel.php create mode 100644 extend/catcher/library/excel/ExcelContract.php 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 @@ +