From cf4ef949b5918dfeffac5e521d0cdb3deb954fd9 Mon Sep 17 00:00:00 2001 From: wuyanwen Date: Tue, 7 Jan 2020 19:00:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/index/controller/Index.php | 9 ++-- catch/login/controller/Index.php | 2 +- catch/user/AuthTokenMiddleware.php | 68 +++++++++++++++--------------- catch/user/controller/User.php | 1 + 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/catch/index/controller/Index.php b/catch/index/controller/Index.php index 36636e7..9f54258 100644 --- a/catch/index/controller/Index.php +++ b/catch/index/controller/Index.php @@ -4,6 +4,7 @@ namespace catchAdmin\index\controller; use catchAdmin\permissions\model\Permissions; use catchAdmin\user\Auth; use catcher\base\CatchController; +use catcher\CatchAuth; use catcher\Tree; use think\facade\Db; @@ -19,7 +20,9 @@ class Index extends CatchController */ public function index(): string { - $permissionIds = Auth::user()->getPermissionsBy(); + $user = (new CatchAuth())->user(); + + $permissionIds = $user->getPermissionsBy(); $menus = Permissions::whereIn('id', $permissionIds) ->where('type', Permissions::MENU_TYPE) @@ -28,7 +31,7 @@ class Index extends CatchController return $this->fetch([ 'menus' => Tree::done($menus), - 'username' => Auth::user()->username, + 'username' => $user->username, ]); } @@ -56,4 +59,4 @@ class Index extends CatchController 'mysql_version' => $mysqlVersion['0']['version'], ]); } -} \ No newline at end of file +} diff --git a/catch/login/controller/Index.php b/catch/login/controller/Index.php index 9f2e235..cd68ec6 100644 --- a/catch/login/controller/Index.php +++ b/catch/login/controller/Index.php @@ -35,7 +35,7 @@ class Index extends CatchController public function login(LoginRequest $request, CatchAuth $auth) { $params = $request->param(); - + $token = $auth->attempt($params); $user = $auth->user(); diff --git a/catch/user/AuthTokenMiddleware.php b/catch/user/AuthTokenMiddleware.php index 5609a25..4109410 100644 --- a/catch/user/AuthTokenMiddleware.php +++ b/catch/user/AuthTokenMiddleware.php @@ -1,34 +1,34 @@ -user(); $roles = $user->getRoles();