Exemplo n.º 1
0
 /**
  * baseController里面提供登录校验的机制
  */
 protected function checkLogin()
 {
     $token = request::get('token');
     $info = Comm::checkLogin($token);
     if ($info === false) {
         // 此处再去校验是不是管理员登陆,如果是管理员登陆的话那就可以是god模式
         $uid = request::get('uid');
         if (!empty($uid)) {
             $this->checkAdminLogin();
             if (!is_object($this->msg)) {
                 return $uid;
                 // 返回前台传过来的UID
             }
         }
         $this->msg = new Msg(-1, '对不起,请先登录');
         exit;
     }
     if (empty($info['enable'])) {
         $this->msg = new Msg(-2, '该账号已被封,请联系管理员');
         exit;
     }
     return $info['uid'];
 }