Beispiel #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;
 }
Beispiel #2
0
 /**
  * @brief 发送验证马
  *
  */
 public function sendVcode($sendType, $uname, $terminal = null)
 {
     if (!$sendType || !$uname) {
         throw new \LogicException(app::get('sysuser')->_('请填写正确的手机号码或者邮箱号'));
         return false;
     }
     $login_type = kernel::single('pam_tools')->checkLoginNameType($uname);
     //手机短信验证码
     if ($sendType && $login_type == 'mobile') {
         if (!userVcode::send_sms($sendType, (string) $uname, $terminal)) {
             throw new \LogicException(app::get('sysuser')->_('验证码发送失败'));
             return false;
         }
     } elseif ($sendType && $login_type == 'email') {
         if (!userVcode::send_email($sendType, (string) $uname, $terminal)) {
             throw new \LogicException(app::get('sysuser')->_('邮件发送失败'));
             return false;
         }
     } else {
         if ($login_type == 'email') {
             throw new \LogicException(app::get('sysuser')->_('请填写正确的邮箱号'));
             return false;
         } elseif ($login_type == 'mobile') {
             throw new \LogicException(app::get('sysuser')->_('请填写正确的手机号'));
             return false;
         } else {
             throw new \LogicException(app::get('sysuser')->_('请填写正确的手机号或者邮箱号'));
             return false;
         }
     }
 }