protected function save() { $this->getEntity()->setOptions(array('senha' => md5($_POST['password']), 'data_troca_senha' => 'now()')); $this->getDataMapper()->save($this->getEntity()); $linkToReset = $_SERVER['HTTP_HOST'] . $this->getRequest()->getBaseurl() . '/' . 'Usuario/AlterarSenha'; UsuarioMailer::updatedPassword($user = $this->getEntity(), $linkToReset); }
protected function updatePassword() { $user = $this->getEntity(); try { if ($this->canUpdate($user)) { $user->setOptions(array('senha' => md5($_POST['password']), 'status_token' => '', 'data_troca_senha' => 'now()')); $this->getDataMapper()->save($user); $linkToReset = $_SERVER['HTTP_HOST'] . $this->getRequest()->getBaseurl() . '/' . 'Usuario/RedefinirSenha'; UsuarioMailer::updatedPassword($user = $this->getEntity(), $linkToReset); // #FIXME adicionar flash ao session, para persistr ao redirecionar ? $this->messenger()->append('Senha alterada com sucesso.', 'success'); $this->logInUser(); } } catch (Exception $e) { $this->messenger()->append('Erro ao atualizar de senha.', 'error'); error_log("Exception ocorrida ao atualizar senha, matricula: {$user->matricula}, erro: " . $e->getMessage()); } }