/**
  * 
  * 登陆处理
  */
 public function doLogin()
 {
     #空提交,踢出去
     if (!$this->_checkVerify(I('post.verify'), 1) || empty($user = I('post.username')) || empty($password = I('post.password', '', 'trim'))) {
         echo parent::errorEcho('非法登陆');
         exit;
     }
     #验证登陆
     $users = new users();
     if ($user = $users->where('username="******"', $user)->find()) {
         #验证密码是否正确
         if (md5($password) !== $user['password']) {
             echo parent::errorEcho('密码不正确');
             exit;
         }
         #登陆成功,将登录信息完整写入
         #根据用户id,获得userInfo表的用户信息和该用户所拥有的所有权限
         $userInfo = D('Userinfo')->where('uid=%d', $user['id'])->find();
         $home = array_merge($userInfo, $user);
         #授权-----------------正在赶工中------------------------
         RBAC::saveAuthList($user);
         $auth = array();
         #....................................................................................................
         session('home', $home);
         session('auth', $auth);
         return true;
     }
 }
 /**
  * 
  * 用户注册方法
  * @param array $data
  */
 public function doAddUser($data)
 {
     #非法操作,踢出去
     if (empty($username = $data['username']) || empty($password = $data['password'])) {
         echo parent::errorEcho('请正确填写用户名和密码', 'Users/addUser');
         exit;
     }
     if ($password !== $data['chkPass']) {
         echo parent::errorEcho('两次输入的密码不一致', 'Users/addUser');
         exit;
     }
     unset($data['chkPass']);
     #实例化Users模型
     $userMod = new UsersModel();
     //如果用户已经存在,则输出错误
     if ($userMod->where('username="******"', $username)->field("username")->find()) {
         echo parent::errorEcho('用户名:' . $username . '已经存在了', 'Users/addUser');
         exit;
     }
     #给users表插入新用户数据
     $data['password'] = md5($data['password']);
     $data['regtime'] = time();
     $uid = $userMod->add($data);
     $data['uid'] = $uid;
     #实例化UserInfo模型
     $userInfoMod = new UserinfoModel();
     if ($userInfoMod->add($data)) {
         echo parent::errorEcho('注册成功', 'Users/addUser');
         exit;
     }
 }