public function confirmEmailChangePasswordAction()
    {
      $token = $this->params()->fromRoute('id');
      try {
        $entityManager = $this->getEntityManager();
        if($token !== '' && $user = $entityManager->getRepository('CsnUser\Entity\User')->findOneBy(array('registrationToken' => $token))) {
          $user->setRegistrationToken(md5(uniqid(mt_rand(), true)));
          $password = $this->generatePassword();
          $user->setPassword(UserCredentialsService::encryptPassword($password));
          $email = $user->getEmail();
          $fullLink = $this->getBaseUrl() . $this->url()->fromRoute('user-index', array( 'action' => 'login'));
          $this->sendEmail(
              $user->getEmail(),
              'Your password has been changed!',
              sprintf($this->getTranslatorHelper()->translate('Hello again %s. Your new password is: %s. Please, follow this link %s to log in with your new password.'), $user->getUsername(), $password, $fullLink)
              
          );          
          $entityManager->persist($user);
          $entityManager->flush();
    
          $viewModel = new ViewModel(array(
              'email' => $email,
              'navMenu' => $this->getOptions()->getNavMenu()
          ));
          return $viewModel;
        } else {
          return $this->redirect()->toRoute('user-index');
        }
      } catch (\Exception $e) {
        return $this->getServiceLocator()->get('csnuser_error_view')->createErrorView(
            $this->getTranslatorHelper()->translate('An error occured during the confirmation of your password change! Please, try again later.'),
            $e,
            $this->getOptions()->getDisplayExceptions(),
            $this->getOptions()->getNavMenu()
        );
      }
    }
public function confirmEmailChangePasswordAction()
    {
      $token = $this->params()->fromRoute('id');
      try {
        $entityManager = $this->getEntityManager();
        if($token !== '' && $user = $entityManager->getRepository('CsnUser\Entity\User')->findOneBy(array('registrationToken' => $token))) {
          $user->setRegistrationToken(md5(uniqid(mt_rand(), true)));
          $password = $this->generatePassword();
          $user->setPassword(UserCredentialsService::encryptPassword($password));
          $email = $user->getEmail();
          $fullLink = $this->getBaseUrl() . $this->url()->fromRoute('user-index', array( 'action' => 'login'));
          $this->sendEmail(
              $user->getEmail(),
              'Your password has been changed!',
              sprintf($this->getTranslatorHelper()->translate('Hello again %s. Your new password is: %s. Please, follow this link %s to log in with your new password.'), $user->getUsername(), $password, $fullLink)
              
          );          
          $entityManager->persist($user);
          $entityManager->flush();
    
          $viewModel = new ViewModel(array(
              'email' => $email,
              'navMenu' => $this->getOptions()->getNavMenu()
          ));
          return $viewModel;
        } else {
          return $this->redirect()->toRoute('user-index');
        }
      } catch (\Exception $e) {
        return $this->getServiceLocator()->get('csnuser_error_view')->createErrorView(
            $this->getTranslatorHelper()->translate('An error occured during the confirmation of your password change! Please, try again later.'),
            $e,
            $this->getOptions()->getDisplayExceptions(),
            $this->getOptions()->getNavMenu()
        );
      }
    }
public function confirmEmailChangePasswordAction ( ) { $ token = $ this -> params ( ) -> fromRoute ( 'id' ) ; try { $ entityManager = $ this -> getEntityManager ( ) ; if ( $ token !== '' && $ user = $ entityManager -> getRepository ( 'CsnUser\Entity\User' ) -> findOneBy ( array ( 'registrationToken' => $ token ) ) ) { $ user -> setRegistrationToken ( md5 ( uniqid ( mt_rand ( ) , true ) ) ) ; $ password = $ this -> generatePassword ( ) ; $ user -> setPassword ( UserCredentialsService :: encryptPassword ( $ password ) ) ; $ email = $ user -> getEmail ( ) ; $ fullLink = $ this -> getBaseUrl ( ) . $ this -> url ( ) -> fromRoute ( 'user-index' , array ( 'action' => 'login' ) ) ; $ this -> sendEmail ( $ user -> getEmail ( ) , 'Your password has been changed!' , sprintf ( $ this -> getTranslatorHelper ( ) -> translate ( 'Hello again %s. Your new password is: %s. Please, follow this link %s to log in with your new password.' ) , $ user -> getUsername ( ) , $ password , $ fullLink ) ) ; $ entityManager -> persist ( $ user ) ; $ entityManager -> flush ( ) ; $ viewModel = new ViewModel ( array ( 'email' => $ email , 'navMenu' => $ this -> getOptions ( ) -> getNavMenu ( ) ) ) ; return $ viewModel ; } else { return $ this -> redirect ( ) -> toRoute ( 'user-index' ) ; } } catch ( \ Exception $ e ) { return $ this -> getServiceLocator ( ) -> get ( 'csnuser_error_view' ) -> createErrorView ( $ this -> getTranslatorHelper ( ) -> translate ( 'An error occured during the confirmation of your password change! Please, try again later.' ) , $ e , $ this -> getOptions ( ) -> getDisplayExceptions ( ) , $ this -> getOptions ( ) -> getNavMenu ( ) ) ; } }
Confirm Email Change Action

Confirms password change through given token

@return Zend\View\Model\ViewModel
Confirm Email Change Action