Example #1
0
 /**
  * 前端注册验证码的发送
  *
  * @param  string $account
  * @return string
  */
 public function sendVcode($account, $sendType)
 {
     if (!$account) {
         throw new \LogicException(app::get('topc')->_('请填写正确的手机号码或者邮箱号'));
     }
     if (!$sendType) {
         throw new \LogicException(app::get('topc')->_('参数错误'));
     }
     $type = kernel::single('pam_tools')->checkLoginNameType($account);
     if ($sendType == 'reset') {
         $data = userAuth::getAccountInfo($account);
         if ($data) {
             throw new \LogicException('该' . $type . '已被使用');
         }
     }
     switch ($type) {
         case "email":
             if (!$this->sendEmailVcode($sendType, $account)) {
                 throw new \LogicException(app::get('topc')->_('邮件发送失败'));
             }
             break;
         case "mobile":
             if (!userVcode::send_sms($sendType, $account)) {
                 throw new \LogicException(app::get('topc')->_('验证码发送失败'));
             }
             break;
         default:
             throw new \LogicException(app::get('topc')->_('验证码发送失败'));
             break;
     }
     return true;
 }
Example #2
0
 public function findPwdThree()
 {
     $postData = utils::_filter_input(input::get());
     $vcode = $postData['vcode'];
     $loginName = $postData['uname'];
     $sendType = $postData['type'];
     $accountType = kernel::single('pam_tools')->checkLoginNameType($loginName);
     try {
         $vcodeData = userVcode::verify($vcode, $loginName, $sendType);
         if (!$vcodeData) {
             throw new \LogicException('验证码输入错误');
         }
     } catch (Exception $e) {
         $msg = $e->getMessage();
         return $this->splash('error', null, $msg);
     }
     $userInfo = userAuth::getAccountInfo($loginName);
     $key = userVcode::getVcodeKey($loginName, $sendType);
     $userInfo['key'] = md5($vcodeData['vcode'] . $key . $userInfo['user_id']);
     $pagedata['data'] = $userInfo;
     $pagedata['account'] = $loginName;
     if ($accountType == "email") {
         return $this->page('topm/passport/forgot/email_three.html', $pagedata);
     } else {
         return $this->page('topm/passport/forgot/three.html', $pagedata);
     }
 }