/** * * @return \Onion\View\Model\ViewModel */ public function forgottenPasswordAction() { $loForm = Application::factory($this->_sForgotten); $loForm->setObjectManager($this->getEntityManager()); $loForm->setActionType('forgotten'); $loForm->setEntity($this->_sEntity); $loForm->setForm(); $lsSecurity = $this->requestPost('security', null); if ($this->requestIsPost() && $lsSecurity !== null) { $loForm->setInputFilter($loForm->getInputFilter()); $loForm->setData($this->requestPost()); if ($loForm->isValid()) { $laData = $loForm->getDataForm(); $lsEmail = String::escapeString($laData['stEmail']); $loEntityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $loUser = $loEntityManager->getRepository($this->_sEntity)->findOneBy(array('stEmail' => $lsEmail)); $lsPassword = String::generatePassword(); if ($this->sendPasswordByEmail($lsEmail, $lsPassword)) { $loUser->setStPassword($lsPassword); $loEntityManager->persist($loUser); $loEntityManager->flush(); } } } return new ViewModel(array('lsTitle' => $this->_sForgottenTitle, 'lsRoute' => $this->_sRoute, 'loForm' => $loForm)); }
/** * * @return object */ public function generatePasswordAction() { $lsPassword = String::generatePassword(); $loView = new ViewModel(); $loView->setTerminal(true); // desabilita o layout $loResponse = $this->getResponse(); $loResponse->setStatusCode(200); $loResponse->setContent(Json::encode($lsPassword)); return $loResponse; }