Ejemplo n.º 1
0
 protected function _beforeAdd()
 {
     if (!$this->dm) {
         return new PwError('USER:user.info.error');
     }
     if (($result = PwUserValidator::isUsernameHasIllegalChar($this->getField('username'))) !== false) {
         return $result;
     }
     if (($result = PwUserValidator::isPwdValid($this->_password, $this->getField('username'))) !== true) {
         return $result;
     }
     if (($result = $this->dm->beforeAdd()) !== true) {
         $errorCode = $result->getCode();
         $var = array();
         if ($errorCode == -2) {
             $windid = WindidApi::api('config');
             $config = $windid->getConfig('reg');
             $var = array('{min}' => $config['namelength.min'], '{max}' => $config['namelength.max']);
         }
         if ($errorCode == -11) {
             $windid = WindidApi::api('config');
             $config = $windid->getConfig('reg');
             $var = array('{min}' => $config['passwordlength.min'], '{max}' => $config['passwordlength.max']);
         }
         return new PwError('WINDID:code.' . $errorCode, $var);
     }
     if (true !== ($result = $this->check())) {
         return $result;
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * 检查密码复杂度是否符合
  */
 public function checkpwdAction()
 {
     list($pwd, $username) = $this->getInput(array('pwd', 'username'), 'post');
     $result = PwUserValidator::isPwdValid($pwd, $username);
     if ($result instanceof PwError) {
         $this->showError($result->getError());
     }
     $this->addMessage(PwUserHelper::checkPwdStrong($pwd), 'rank');
     $this->showMessage();
 }
Ejemplo n.º 3
0
 /**
  * 密码校验,ajax action
  */
 public function checkpwdAction()
 {
     $returnData = array("success" => true, "data" => "更新成功");
     $pwd = $this->getInput('pwd', 'post');
     $result = PwUserValidator::isPwdValid($pwd, $this->loginUser->username);
     if ($result instanceof PwError) {
         $resource = Wind::getComponent('i18n');
         list($_pwdMsg, $_pwdArgs) = PwUserValidator::buildPwdShowMsg();
         $message = $resource->getMessage($_pwdMsg, $_pwdArgs);
         $returnData['success'] = false;
         $returnData['data'] = $message;
         print_r(json_encode($returnData));
         die;
     }
     $userDm = new PwUserInfoDm($this->loginUser->uid);
     $userDm->setUsername($this->loginUser->username);
     $userDm->setPassword($pwd);
     /* @var $userDs PwUser */
     $userDs = Wekit::load('user.PwUser');
     if (($result = $userDs->editUser($userDm, PwUser::FETCH_MAIN)) instanceof PwError) {
         $message = $result->getError();
         $returnData['success'] = false;
         $returnData['data'] = $message;
         print_r(json_encode($returnData));
         die;
     }
     $this->loginUser->reset();
     print_r(json_encode($returnData));
     die;
 }
Ejemplo n.º 4
0
 protected function _beforeAdd()
 {
     if (!$this->dm) {
         return new PwError('USER:user.info.error');
     }
     if (($result = PwUserValidator::isUsernameHasIllegalChar($this->getField('username'))) !== false) {
         return $result;
     }
     if (($result = PwUserValidator::isPwdValid($this->_password, $this->getField('username'))) !== true) {
         return $result;
     }
     if (WINDID_CONNECT == 'db' && ($result = $this->dm->beforeAdd()) !== true) {
         return $this->_getWindidMsg($result);
     }
     if (true !== ($result = $this->check())) {
         return $result;
     }
     return true;
 }