From 32b87baeee58b8e873912f7380fe66d4637fe412 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Mon, 13 Jul 2020 17:07:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20Request=20=E8=AE=A4?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Request.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/Request.php b/app/Request.php index 478a693..0038d01 100644 --- a/app/Request.php +++ b/app/Request.php @@ -14,20 +14,21 @@ class Request extends \think\Request { protected $auth; - /** - * login user - * - * @time 2020年01月09日 - * @return mixed - */ - public function user() + /** + * login user + * + * @time 2020年01月09日 + * @param null $guard + * @return mixed + */ + public function user($guard = null) { if (!$this->auth) { $this->auth = new CatchAuth; } try { - $user = $this->auth->user(); + $user = $this->auth->guard($guard ? : config('catch.auth.default.guard'))->user(); } catch (\Exception $e) { if ($e instanceof TokenExpiredException) { throw new FailedException('token 过期', Code::LOGIN_EXPIRED);