From 6e1f870e21e372750a261d236b39d7f48e46b639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Fri, 12 Oct 2018 16:57:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=AD=E9=97=B4=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/controller/Base.php | 20 ++++--------- application/error/controller/Index.php | 22 +++++++++++++++ application/http/middleware/YanZheng.php | 28 +++++++++++++++++++ application/index/controller/Index.php | 3 +- .../migrations/20181010075304_auth_group.php | 2 +- 5 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 application/error/controller/Index.php create mode 100644 application/http/middleware/YanZheng.php diff --git a/application/common/controller/Base.php b/application/common/controller/Base.php index 885f908e..de56e575 100644 --- a/application/common/controller/Base.php +++ b/application/common/controller/Base.php @@ -11,22 +11,12 @@ use think\auth\Auth; class Base extends Controller { - // 当前类初始化 - protected function initialize() + // 调用Auth中间件进行用户权限验证 + protected $middleware = ['YanZheng']; + + public function _empty() { - $this->quanxianyanzheng(); + $this->redirect('error/index/index'); } - protected function quanxianyanzheng() - { - // 实例化权限验证Auth类 - $auth = new Auth(); - - // 检测权限 - // if($auth->check('show_button',1)){// 第一个参数是规则名称,第二个参数是用户UID - // //有显示操作按钮的权限 - // }else{ - // //没有显示操作按钮的权限 - // } - } } diff --git a/application/error/controller/Index.php b/application/error/controller/Index.php new file mode 100644 index 00000000..5dcb93d8 --- /dev/null +++ b/application/error/controller/Index.php @@ -0,0 +1,22 @@ +check('show_button',1)){// 第一个参数是规则名称,第二个参数是用户UID + // //有显示操作按钮的权限 + // }else{ + // //没有显示操作按钮的权限 + // } + + + $request->hello = 'ThinkPHP'; + $a = $request->action(); + + return $next($request); + } +} diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index 2dd6e368..93a05834 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -10,8 +10,6 @@ use think\auth\Auth; class Index extends Base { - //关闭自动时间 - protected $autoWriteTimestamp = false; // 初始化 protected function initialize() @@ -29,6 +27,7 @@ class Index extends Base $sysbasemod->title = '学生成绩统计系统'; $sysbasemod->save(); } + dump('index初始化'); } diff --git a/database/migrations/20181010075304_auth_group.php b/database/migrations/20181010075304_auth_group.php index 6328fcef..39112696 100644 --- a/database/migrations/20181010075304_auth_group.php +++ b/database/migrations/20181010075304_auth_group.php @@ -29,7 +29,7 @@ class AuthGroup extends Migrator public function change() { // 定义数据表名称 - $table = $this->table('auth_rule_group'); + $table = $this->table('auth_group'); // 添加当前表字段 $table