Пример #1
0
 /**
  * [checkcapAction description]
  * @return [type] [1 成功,10004 手机号未注册]
  */
 public function checkcapAction()
 {
     if (!$this->validFlag) {
         echo json_encode(array('ret' => 0, 'msg' => $this->warnMsg));
     } else {
         $objCaptcha = new Captcha();
         $key = 'resetPwd:' . $this->_sanReq['mobile'];
         $data = $objCaptcha->checkAllCaptcha($this->_sanReq['mobile'], $this->_sanReq['codeImg'], $key, $this->_sanReq['regtype'], $this->_sanReq['captcha']);
         if ($data == 1) {
             $user = new User();
             $res = $user->existTel($this->_sanReq['mobile']);
             if (!$res) {
                 echo json_encode(array('ret' => 0, 'msg' => array('email' => array('msg' => $this->di['sysconfig']['flagMsg']['10004']))));
             }
             $token = \Ucenter\Utils\Inputs::makeSecert($this->_sanReq['mobile'], $_SERVER['REQUEST_TIME']);
             $this->session->set('resetToken', $token);
             $this->session->set('resetMobile', $this->_sanReq['mobile']);
             $objCaptcha->delCaptchaRedisKey($key);
             echo json_encode(array('ret' => 1));
         } else {
             echo json_encode(array('ret' => 0, 'msg' => $data));
         }
     }
     exit;
 }
Пример #2
0
 /**
  * 生成短信验证码
  * 判断用户获得验证码的资格:type:
  * 1 - 已经注册过的用户不能再次获取注册验证码
  * 7 - 只有注册过的用户才能获取忘记密码的验证码
  * 9 - 只有注册过的用户才能获取修改密码的验证码
  * 11 - 只有注册过的用户才能获取更换邮箱验证码
  */
 public function makeMsg($type, $mobi)
 {
     require_once dirname(dirname(__FILE__)) . '/utils/rpcService.php';
     $lastCapthaInfo = $this->captcha->getLastCapthaInfo($mobi, $type);
     if ($_SERVER['REQUEST_TIME'] - $lastCapthaInfo['mc_addtime'] < 60) {
         return false;
     }
     $res = $this->users->getUidByMobi($mobi);
     switch ($type) {
         case 1:
             if ($res) {
                 exit('90002');
             }
             $content = $this->di['sysconfig']['regMsg'];
             break;
         case 7:
             if (empty($res)) {
                 exit('90001');
             }
             $content = $this->di['sysconfig']['resetMsg'];
             break;
         case 9:
             if (empty($res)) {
                 exit('90001');
             }
             $content = $this->di['sysconfig']['changeMsg'];
             break;
         case 11:
             if (empty($res)) {
                 exit('90001');
             }
             $content = $this->di['sysconfig']['chaEmailMsg'];
             break;
     }
     //生成验证码
     $captcha = \Ucenter\Utils\Inputs::random(4);
     $RedisLib = new \Ucenter\Utils\RedisLib($this->di);
     $redis = $RedisLib::getRedis();
     if ($redis->get($mobi . $type) == FALSE) {
         $redis->set($mobi . $type, $captcha, 1800);
     }
     $captcha = $redis->get($mobi . $type);
     $data = $this->captcha->addCaptcha($mobi, $type, $_SERVER['REQUEST_TIME'], $captcha);
     //验证码入库
     if ($data) {
         $sendMsg = new \rpcService\RpcService($this->di['sysconfig']['thrift']['ip'], $this->di['sysconfig']['thrift']['port']);
         $sendMsg->smsSend($mobi, sprintf($content, $captcha));
         return true;
     } else {
         exit('90018');
     }
 }
Пример #3
0
 /**
  * 设一个隐藏标签regtype = 11
  * [checkcapAction 检查手机和验证码]
  * @return [type] [1验证码有效,]
  */
 public function checkcapAction()
 {
     if (!$this->validFlag) {
         echo json_encode(array('ret' => 0, 'msg' => $this->warnMsg));
     } else {
         $objCaptcha = new Captcha();
         $key = 'email:' . $this->session->get('uinfo')['mobile'];
         $data = $objCaptcha->checkAllCaptcha($this->session->get('uinfo')['mobile'], $this->_sanReq['codeImg'], $key, $this->_sanReq['regtype'], $this->_sanReq['captcha']);
         if ($data == 1) {
             $token = \Ucenter\Utils\Inputs::makeSecert($this->session->get('uinfo')['mobile'], $_SERVER['REQUEST_TIME']);
             $this->session->set('emailToken', $token);
             $objCaptcha->delCaptchaRedisKey($key);
             echo json_encode(array('ret' => 1));
         } else {
             echo json_encode(array('ret' => 0, 'msg' => $data));
         }
     }
     exit;
 }
Пример #4
0
 /**
  * [changePwd description]
  * @param  [string] $uid    [用户id]
  * @param  [string] $newPwd [新密码]
  * @param  [string] $regtime [注册时间]
  * @return [bool]
  */
 public function changePwd($uid, $newPwd)
 {
     $userInfo = $this->user->getUserInfo($uid);
     $pwd = \Ucenter\Utils\Inputs::makeSecert($newPwd, $userInfo['u_regtime']);
     return $this->user->updatePwd($uid, $pwd);
 }
Пример #5
0
 /**
  * 修改密码
  * @param unknown $uid
  * @param unknown $passNew
  */
 protected function reset($mobi, $passNew, $regtime)
 {
     return $this->usermodel->updatePwdByMobi($mobi, Inputs::makeSecert($passNew, $regtime));
 }