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()));
 }
 /**
  *
  * @param MvcAuthEvent $mvcAuthEvent
  * @throws \Dws\Exception\Service\ModelNotFoundException
  */
 public function __invoke(MvcAuthEvent $mvcAuthEvent)
 {
     // Add validated identity to ZfcUser storage
     $identity = $mvcAuthEvent->getIdentity();
     if ($identity instanceof AuthenticatedIdentity) {
         $user = $this->userService->getUserMapper()->findById($identity->getAuthenticationIdentity()['user_id']);
         if ($user) {
             $this->authenticationService->getStorage()->write($user);
         }
         $identity->setName(implode(', ', $user->getRoles()->toArray()));
     }
 }
Exemple #3
0
 /**
  * @covers ZfcUser\Service\User::getUserMapper
  */
 public function testGetUserMapper()
 {
     $this->serviceManager->expects($this->once())->method('get')->with('zfcuser_user_mapper')->will($this->returnValue($this->mapper));
     $service = new Service();
     $service->setServiceManager($this->serviceManager);
     $this->assertInstanceOf('ZfcUser\\Mapper\\UserInterface', $service->getUserMapper());
 }