Beispiel #1
0
 /**
  * Authenticate
  *
  * Authenticate the username and password
  *
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     $codeError = Zend_Auth_Result::FAILURE;
     $userRow = DbTable_User::getInstance()->fetchRow(array('Login = ?' => $this->getUsername()));
     if (!$userRow) {
         return new Zend_Auth_Result($codeError, null, array('Authentication error'));
     }
     $hashedPassword = Vtx_Util_String::hashMe($this->getPassword(), $userRow->getSalt());
     if ($hashedPassword['sha'] != $userRow->getKeypass()) {
         return new Zend_Auth_Result($codeError, null, array('Authentication error'));
     }
     return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $userRow, array());
 }
Beispiel #2
0
 function updateUser($userRowData, $data)
 {
     $verifylogin = DbTable_User::getInstance()->fetchRow(array('Login = ?' => $data['login'], 'Id != ?' => $userRowData->getId()));
     if ($verifylogin) {
         return array('status' => false, 'messageError' => 'Nome de usuário (login) em uso.');
     }
     if (isset($data['change_password'])) {
         unset($data['change_password']);
         $data['password'] = $data['keypass'];
     }
     if (isset($data['password'])) {
         if ($data['keypass'] != $data['keypass_confirm'] or empty($data['keypass'])) {
             return array('status' => false, 'messageError' => 'Senha não confere.');
         }
         $pass = Vtx_Util_String::hashMe(md5($data['password']));
     }
     $data = $this->_filterInputUser($data)->getUnescaped();
     $userRowData->setPositionId(isset($data['position_id']) ? $data['position_id'] : $userRowData->getPositionId())->setEducationId(isset($data['education_id']) ? $data['education_id'] : $userRowData->getEducationId())->setBornDate(isset($data['born_date']) ? Vtx_Util_Date::format_iso($data['born_date']) : $userRowData->getBornDate())->setGender(isset($data['gender']) ? $data['gender'] : $userRowData->getGender())->setCpf(isset($data['cpf']) ? $data['cpf'] : $userRowData->getCpf())->setKeypass(isset($data['password']) ? $pass['sha'] : $userRowData->getKeypass())->setSalt(isset($data['password']) ? $pass['salt'] : $userRowData->getSalt())->setFirstName(isset($data['first_name']) ? $data['first_name'] : $userRowData->getFirstName())->setSurname(isset($data['surname']) ? $data['surname'] : $userRowData->getSurname())->setEmail(isset($data['email']) ? $data['email'] : $userRowData->getEmail())->setLogin(isset($data['login']) ? $data['login'] : $userRowData->getLogin())->setPasswordHint(isset($data['password_hint']) ? $data['password_hint'] : $userRowData->getPasswordHint())->setStatus(isset($data['status']) ? $data['status'] : $userRowData->getLogin());
     //'13302', NULL, NULL, 'VANESSA ZULIAN', '', '000.001.340-40', '*****@*****.**', '40ef7e139a734b368975ca4eb01bbb80b224e4dc241f5a767bb57d593d9e65128dfb7f97ba198bbcce89183d925f6a9e0927487cc1c8cfd1a5bfc80d58c06bef', 'deaaf66b0e537f2', '', NULL, NULL, NULL, '123 teste'
     $userRowData->save();
     return array('status' => true);
 }
Beispiel #3
0
 /**
  * altera password do usuario
  *
  * @param type $IdUser
  * @return type
  */
 public function setPassword($IdUser)
 {
     $senhaRandon = substr(uniqid(), -8);
     //pass com 8 caracteres
     $senhaToMd5 = md5($senhaRandon);
     $pass = Vtx_Util_String::hashMe($senhaToMd5);
     $keypass = $pass['sha'];
     $salt = $pass['salt'];
     $User = new Model_User();
     $userRowData = $User->getUserById($IdUser);
     $userRowData->setKeypass($keypass);
     $userRowData->setSalt($salt);
     $userRowData->save();
     return array('status' => true, 'senhaRandon' => $senhaRandon, 'userObj' => $userRowData);
 }