123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace app\base\controller;
- use think\Controller;
- use think\Auth;
- use app\user\model\Mail;
- /**
- * 创建控制器基类
- * @author Superbee
- *
- */
- class Base extends Controller{
-
- private $mailModel;
-
- public function _initialize(){
- parent::_initialize();
-
- $this->assign("rootpath", $this->request->root());
-
- $this->check_login();
- $this->check_auth();
- }
-
- /**
- * 检测是否登录
- */
- private function check_login(){
- $admin = session('admin');
-
- if(empty($admin)){
- $this->redirect($this->request->root().'/base/login/login');
- }
- }
-
- /**
- * 检查权限
- */
- private function check_auth(){
- $m = $this->request->module ();
- $c = $this->request->controller ();
- $a = $this->request->action ();
- $rule_name = '/'.$m.'/'.$c.'/'.$a;
-
- $auth = new Auth();
- $admin = session('admin');
- $result = $auth->check($rule_name, $admin['id']);
- // if(!$result){
- // $this->error('您没有权限访问');
- // }
- }
-
- }
|