Ejemplo n.º 1
0
 /**
  * 验证手机验证码
  */
 public function checkmobilecodeAction()
 {
     if (!$this->isMobileOpen) {
         $this->showError('USER:findpwd.way.mobile.close', 'u/findPwd/run');
     }
     list($mobileCode, $mobile) = $this->getInput(array('mobileCode', 'mobile'), 'post');
     //get username by mobile
     $userMobile = $this->_getUserMobileDs()->getByMobile($mobile);
     if (empty($userMobile)) {
         $this->showError('非注册手机号,请填写正确', 'u/findPwd/run');
     }
     !$mobileCode && $this->showError('USER:mobile.code.empty', 'u/findPwd/run');
     $uid = $userMobile['uid'];
     $userInfo = $this->_getUserDs()->getUserByUid($uid);
     if (empty($userInfo)) {
         $this->showError("无此用户");
     }
     $username = $userInfo['username'];
     if (($mobileCheck = Wekit::load('mobile.srv.PwMobileService')->checkVerify($mobile, $mobileCode)) instanceof PwError) {
         $this->showError($mobileCheck->getError());
     }
     $statu = PwFindPassword::createFindPwdIdentify($username, PwFindPassword::WAY_MOBILE, $mobile);
     $this->showMessage('success', 'u/findPwd/resetpwd?way=mobile&_statu=' . $statu . '&mobile=' . $mobile . '&mobileCode=' . $mobileCode);
 }
Ejemplo n.º 2
0
 /**
  * 验证手机验证码
  */
 public function checkmobilecodeAction()
 {
     if (!$this->isMobileOpen) {
         $this->showError('USER:findpwd.way.mobile.close', 'u/findPwd/run');
     }
     list($username, $mobileCode, $mobile) = $this->getInput(array('username', 'mobileCode', 'mobile'), 'post');
     !PwUserValidator::isMobileValid($mobile) && $this->showError('USER:error.mobile', 'u/findPwd/run');
     !$mobileCode && $this->showError('USER:mobile.code.empty', 'u/findPwd/run');
     $userInfo = $this->_getUserDs()->getUserByName($username, PwUser::FETCH_INFO);
     if ($userInfo['mobile'] != $mobile) {
         $this->showError('USER:findpwd.error.mobile');
     }
     if (($mobileCheck = Wekit::load('mobile.srv.PwMobileService')->checkVerify($mobile, $mobileCode)) instanceof PwError) {
         $this->showError($mobileCheck->getError());
     }
     $statu = PwFindPassword::createFindPwdIdentify($username, PwFindPassword::WAY_MOBILE, $mobile);
     $this->showMessage('success', 'u/findPwd/resetpwd?way=mobile&_statu=' . $statu . '&mobile=' . $mobile . '&mobileCode=' . $mobileCode);
 }
Ejemplo n.º 3
0
 /**
  * 找回密码
  *
  * @access public
  * @return void
  */
 public function findPwdAction()
 {
     $step = $this->getInput('step');
     $username = $this->getInput('username');
     //
     Wind::import('SRV:user.srv.PwFindPassword');
     $findPasswordBp = new PwFindPassword($username);
     //
     switch ($step) {
         case 1:
             //返回混淆的email
             $email = $findPasswordBp->getFuzzyEmail();
             $this->setOutput($email, 'data');
             $this->showMessage('success');
             break;
         case 2:
             //通过username&email发送邮件
             $email = $this->getInput('email');
             /*检查邮箱是否正确*/
             if (true !== ($result = $findPasswordBp->checkEmail($email))) {
                 $this->showError($result->getError());
             }
             /*发送重置邮件*/
             if (!$findPasswordBp->sendResetEmail(PwFindPassword::createFindPwdIdentify($username, PwFindPassword::WAY_EMAIL, $email))) {
                 $this->showError('USER:findpwd.error.sendemail');
             }
             $this->showMessage('USER:active.sendemail.success');
             break;
         case 3:
             //_statu 找回密码
             $statu = $this->getInput('_statu', 'get');
             !$statu && ($statu = $this->getInput('statu', 'post'));
             if (!$statu) {
                 $this->showError('USER:illegal.request');
             }
             list($username, $way, $value) = PwFindPassword::parserFindPwdIdentify($statu);
             $userInfo = $this->_getUserDs()->getUserByName($username, PwUser::FETCH_INFO | PwUser::FETCH_MAIN);
             if ($userInfo[PwFindPassword::getField($way)] != $value) {
                 $this->showError('fail');
             }
             //
             $code = $this->getInput('code', 'get');
             $findPasswordBp = new PwFindPassword($userinfo['username']);
             if ($way == PwFindPassword::WAY_EMAIL) {
                 if ($findPasswordBp->isOverByMail()) {
                     $this->showError('USER:findpwd.over.limit.email');
                 }
                 if (($result = $findPasswordBp->checkResetEmail($value, $code)) instanceof PwError) {
                     $this->showError($result->getError());
                 }
             }
             $this->showMessage("USER:findpwd.over.validate.success");
             break;
         case 4:
             $statu = $this->getInput('_statu', 'get');
             !$statu && ($statu = $this->getInput('statu', 'post'));
             if (!$statu) {
                 $this->showError('USER:illegal.request');
             }
             list($username, $way, $value) = PwFindPassword::parserFindPwdIdentify($statu);
             $userInfo = $this->_getUserDs()->getUserByName($username, PwUser::FETCH_INFO | PwUser::FETCH_MAIN);
             if ($userInfo[PwFindPassword::getField($way)] != $value) {
                 $this->showError('fail');
                 $this->forwardAction('u/findPwd/run', array(), true);
             }
             //
             list($password, $repassword) = $this->getInput(array('password', 'repassword'), 'post');
             if ($password != $repassword) {
                 $this->showError('USER:user.error.-20');
             }
             $userDm = new PwUserInfoDm($userInfo['uid']);
             $userDm->setUsername($userInfo['username']);
             $userDm->setPassword($password);
             $userDm->setQuestion('', '');
             /* @var $userDs PwUser */
             $userDs = Wekit::load('user.PwUser');
             $result = $this->_getUserDs()->editUser($userDm, PwUser::FETCH_MAIN);
             if ($result instanceof PwError) {
                 $this->showError($result->getError());
             } else {
                 //检查找回密码次数及更新
                 $findPasswordBp = new PwFindPassword($userInfo['username']);
                 $findPasswordBp->success($type);
             }
             $this->showMessage('USER:findpwd.success');
             break;
     }
 }