Example #1
0
 /**
  * 登陆
  *
  * @access public
  * @param string phoneNum 手机号
  * @param string password 登陆密码md5
  * @return array
  */
 public function login()
 {
     #参数检查
     $this->params = $this->require_params(array('phoneNum', 'password'));
     //if (!FValidator::phone($this->params['phoneNum'])) throw new Exception('手机号格式非法', 100);
     #获取用户id
     $userId = $this->userModel->getUserIdByUsername($this->params['phoneNum']);
     if (!$userId) {
         throw new Exception('用户不存在', 101);
     }
     #获取用户账户信息
     $accountInfo = $this->userModel->getAccountInfo($userId);
     if ($accountInfo[$this->params['phoneNum']]['password'] != md5(md5($this->params['password']))) {
         throw new Exception('密码错误', 102);
     }
     unset($accountInfo);
     #生成相关授权信息
     $this->returnData = $this->userModel->createToken($userId);
     $this->userLog($userId, __CLASS__ . '/' . __FUNCTION__, serialize($this->params));
     F::rest()->show_result($this->returnData);
 }