Exemple #1
0
 /**
  * 忘记密码后的修改密码
  * 
  * @return boolean
  */
 public function forgetdAction()
 {
     if ($this->isPost()) {
         $iUserID = (int) $this->getParam('u');
         $sCode = $this->getParam('c');
         $aCode = Model_VerifyCode::getCode($iUserID, Model_VerifyCode::TYPE_USER_FORGET, $sCode);
         if (empty($aCode)) {
             return $this->show404();
         }
         $aParam = $this->getParams();
         if (empty($aParam['sPassword']) || empty($aParam['sRePassword']) || !Util_Validate::isLength($aParam['sPassword'], 6, 20)) {
             return $this->showMsg('登录密码长度为6-20个字符!', false);
         }
         if ($aParam['sPassword'] != $aParam['sRePassword']) {
             return $this->showMsg('登录密码两次输入不一致!', false);
         }
         $sNewPassword = Model_User::makePassword($aParam['sPassword']);
         Model_User::updData(array('sPassword' => $sNewPassword, 'iUserID' => $aCode['iUserID']));
         return $this->showMsg('密码修改成功!', true);
     } else {
         $iUserID = (int) $this->getParam('u');
         $sCode = $this->getParam('c');
         $aUser = Model_User::getDetail($iUserID);
         if (empty($aUser)) {
             return $this->show404();
         }
         $aCode = Model_VerifyCode::getCode($iUserID, Model_VerifyCode::TYPE_USER_FORGET, $sCode);
         if (empty($aCode)) {
             return $this->show404();
         }
         $this->assign('aCode', $aCode);
         $this->setMeta('common_page', array('sTitle' => '用户忘记密码'));
     }
 }