public function resetAction() { if ($this->zfcUserAuthentication()->hasIdentity()) { return $this->redirect()->toRoute('zfcuser'); } $this->passwordService->cleanExpiredForgotRequests(); $form = $this->getResetForm(); $userId = $this->params()->fromRoute('userId', null); $token = $this->params()->fromRoute('token', null); $passwordRequest = $this->passwordService->getPasswordMapper()->findByUserIdRequestKey($userId, $token); //no request for a new password found if ($passwordRequest === null || $passwordRequest == false) { return $this->redirect()->toRoute('zfcuser/forgotpassword'); } $user = $this->userService->getUserMapper()->findById($userId); if ($this->getRequest()->isPost()) { $form->setData($this->getRequest()->getPost()); if ($form->isValid() && $user !== null) { $this->passwordService->resetPassword($passwordRequest, $user, $form->getData()); $vm = new ViewModel(array('email' => $user->getEmail())); $vm->setTemplate('goalio-forgot-password/forgot/passwordchanged'); return $vm; } } // Render the form return new ViewModel(array('resetForm' => $form, 'userId' => $userId, 'token' => $token, 'email' => $user->getEmail())); }