Пример #1
0
 public function definirSenhaAction()
 {
     $this->_helper->layout->setLayout('twbs3/front-page');
     $hashedToken = $this->getRequest()->getParam('hashedToken');
     if (empty($hashedToken)) {
         $this->_helper->flashMessenger->addMessage(array('warning' => _('Verification token not informed.')));
         return $this->_helper->redirector->goToRoute(array(), 'login', true);
     }
     $id = $this->getRequest()->getParam('id');
     if (empty($id)) {
         $this->_helper->flashMessenger->addMessage(array('warning' => _('User not informed.')));
         return $this->_helper->redirector->goToRoute(array(), 'login', true);
     }
     $pessoa = new Application_Model_Pessoa();
     try {
         $pessoa->verificarToken($id, $hashedToken);
     } catch (Exception $e) {
         $this->_helper->flashMessenger->addMessage(array('danger' => $e->getMessage()));
         return $this->_helper->redirector->goToRoute(array(), 'login', true);
     }
     $form = new Application_Form_DefinirSenha();
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         $values = $form->getValues();
         try {
             if (strcmp($values['nova_senha'], $values['repetir_nova_senha']) == 0) {
                 $pessoa->setNovaSenha($id, $values['nova_senha']);
                 $pessoa->resetarToken($id);
                 $this->_helper->flashMessenger->addMessage(array('success' => _('Password successfully updated!')));
                 return $this->_helper->redirector->goToRoute(array(), 'login', true);
             } else {
                 $this->_helper->flashMessenger->addMessage(array('warning' => _('The passwords must match!')));
             }
         } catch (Exception $e) {
             $this->_helper->flashMessenger->addMessage(array('danger' => $e->getMessage()));
         }
     }
     // cria form e envia pra view
     $this->view->form = $form;
 }
Пример #2
0
 public function alterarSenhaAction()
 {
     $this->autenticacao();
     $sessao = Zend_Auth::getInstance()->getIdentity();
     $idPessoa = $sessao["idPessoa"];
     $pessoa = new Application_Model_Pessoa();
     $form = new Application_Form_AlterarSenha();
     $this->view->form = $form;
     $data = $this->getRequest()->getPost();
     if ($this->getRequest()->isPost() && $form->isValid($data)) {
         $data = $form->getValues();
         $email = $sessao["email"];
         $resultadoConsulta = $pessoa->avaliaLogin($email, $data['senhaAntiga']);
         if ($resultadoConsulta != null) {
             if ($data['senhaNova'] == $data['senhaNovaRepeticao']) {
                 $pessoa->setNovaSenha($resultadoConsulta['id_pessoa'], $data['senhaNova']);
                 $this->_helper->flashMessenger->addMessage(array('success' => _('Password successfully updated!')));
                 return $this->_helper->redirector->goToRoute(array('controller' => 'participante'), 'default', true);
             } else {
                 $this->_helper->flashMessenger->addMessage(array('warning' => _('The passwords must match!')));
             }
         } else {
             $this->_helper->flashMessenger->addMessage(array('danger' => _('Old password incorrect.')));
         }
     }
     $this->view->id = $idPessoa;
     $sql = $pessoa->getAdapter()->quoteInto('id_pessoa = ?', $idPessoa);
     $this->view->user = $pessoa->fetchRow($sql);
 }