public function isValid() { $lbValid = parent::isValid(); if (!empty($this->data['stOldPassword'])) { $lsPasswordGiven = String::encriptPassword($this->data['stOldPassword'], $this->getEntityData()->get('stPasswordSalt')); if ($lsPasswordGiven == $this->getEntityData()->get('stPassword')) { if ($this->data['stOldPassword'] != $this->data['stPassword']) { if ($this->data['stPassword'] != $this->data['stConfirmation']) { $lbValid = false; $this->get('stConfirmation')->setMessages(array(Translator::i18n('A confirmação não confere com a senha!'))); } } else { $lbValid = false; $this->get('stPassword')->setMessages(array(Translator::i18n('A nova senha deve ser diferente da senha atual!'))); } } else { $lbValid = false; $this->get('stOldPassword')->setMessages(array(Translator::i18n('A senha atual não confere com a registrada!'))); } } else { $this->data['stPassword'] = $this->getEntityData()->get('stPassword'); } return $lbValid; }
/** * * @param string $psValue * @return \User\Entity\User */ public function setStPassword($psValue) { $psValue = trim($psValue); if (!empty($psValue) && $this->stPassword != $psValue) { if (empty($this->stPasswordSalt)) { $this->setStPasswordSalt(); } $psValue = String::encriptPassword($psValue, $this->stPasswordSalt); $this->stPassword = $psValue; } return $this; }
public function isValidx() { $lbValid = parent::isValid(); if ($this->getActionType() == 'add') { $loFound = $this->getObjectManager()->getRepository($this->_sEntity)->findOneBy(array('stUsername' => String::escapeString($this->data['stUsername']))); if (is_object($loFound)) { $lbValid = false; $this->get('stUsername')->setMessages(array(Translator::i18n('Este nome de usuário já está sendo utilizado!'))); } $loFound = $this->getObjectManager()->getRepository($this->_sEntity)->findOneBy(array('stEmail' => String::escapeString($this->data['stEmail']))); if (is_object($loFound)) { $lbValid = false; $this->get('stEmail')->setMessages(array(Translator::i18n('Este email de contato já está sendo utilizado!'))); } if ($this->data['stPassword'] != $this->data['stConfirmation']) { $lbValid = false; $this->get('stConfirmation')->setMessages(array(Translator::i18n('A confirmação da senha não confere!'))); } } else { $this->data['stUsername'] = $this->getEntityData()->get('stUsername'); $loFound = $this->getObjectManager()->getRepository($this->_sEntity)->findOneBy(array('stEmail' => String::escapeString($this->data['stEmail']))); if (is_object($loFound) && $loFound->get('id') != $this->data['id']) { $lbValid = false; $this->get('stEmail')->setMessages(array(Translator::i18n('Este email de contato já está sendo utilizado!'))); } if (!empty($this->data['stOldPassword'])) { $lsPasswordGiven = String::encriptPassword($this->data['stOldPassword'], $this->getEntityData()->get('stPasswordSalt')); if ($lsPasswordGiven == $this->getEntityData()->get('stPassword')) { if ($this->data['stOldPassword'] != $this->data['stPassword']) { if ($this->data['stPassword'] != $this->data['stConfirmation']) { $lbValid = false; $this->get('stConfirmation')->setMessages(array(Translator::i18n('A confirmação não confere com a senha!'))); } } else { $lbValid = false; $this->get('stPassword')->setMessages(array(Translator::i18n('A nova senha deve ser diferente da senha atual!'))); } } else { $lbValid = false; $this->get('stOldPassword')->setMessages(array(Translator::i18n('A senha atual não confere com a registrada!'))); } } else { $this->data['stPassword'] = $this->getEntityData()->get('stPassword'); } } return $lbValid; }