/**
  * Validation method
  *
  * @param mixed $password
  *
  * @return bool
  */
 public function isValid($password)
 {
     $result = true;
     if (!\Evoweb\SfRegister\Services\Login::isLoggedIn()) {
         $this->addError(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_changepassword_notloggedin', 'SfRegister'), 1301599489);
         $result = false;
     } else {
         $user = $this->userRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
         if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('saltedpasswords') && \TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled('FE')) {
             /** @var \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface $saltedPassword */
             $saltedPassword = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance($user->getPassword(), null);
             if (!$saltedPassword->checkPassword($password, $user->getPassword())) {
                 $this->addError(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_changepassword_notequal', 'SfRegister'), 1301599507);
                 $result = false;
             }
         } elseif ($this->settings['encryptPassword'] === 'md5') {
             if (md5($password) !== $user->getPassword()) {
                 $this->addError(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_changepassword_notequal', 'SfRegister'), 1301599507);
                 $result = false;
             }
         } elseif ($this->settings['encryptPassword'] === 'sha1') {
             if (sha1($password) !== $user->getPassword()) {
                 $this->addError(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_changepassword_notequal', 'SfRegister'), 1301599507);
                 $result = false;
             }
         }
     }
     return $result;
 }
 /**
  * If the given passwords are valid
  *
  * @param string $value The value
  *
  * @return boolean
  */
 public function isValid($value)
 {
     $result = true;
     if ($this->userRepository->countByField($this->propertyName, $value)) {
         $this->addError(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_notunique_local', 'SfRegister'), 1301599608);
         $result = false;
     } elseif ($this->options['global'] && $this->userRepository->countByFieldGlobal($this->propertyName, $value)) {
         $this->addError(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_notunique_global', 'SfRegister'), 1301599619);
         $result = false;
     }
     return $result;
 }
 /**
  * Determines the frontend user, either if it's
  * already submitted, or by looking up the mail hash code.
  *
  * @param NULL|\Evoweb\SfRegister\Domain\Model\FrontendUser $user
  * @param NULL|string $hash
  * @return NULL|\Evoweb\SfRegister\Domain\Model\FrontendUser
  */
 protected function determineFrontendUser(\Evoweb\SfRegister\Domain\Model\FrontendUser $user = null, $hash = null)
 {
     $frontendUser = null;
     $requestArguments = $this->request->getArguments();
     if ($user !== null && $hash !== null) {
         $calculatedHash = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac($requestArguments['action'] . '::' . $user->getUid());
         if ($hash === $calculatedHash) {
             $frontendUser = $user;
         }
         // @deprecated authCode is still there for backward compatibility
     } elseif (!empty($requestArguments['authCode'])) {
         $frontendUser = $this->userRepository->findByMailhash($requestArguments['authCode']);
     }
     return $frontendUser;
 }
 /**
  * Actually convert from $source to $targetType, taking into account the fully
  * built $convertedChildProperties and $configuration.
  * The return value can be one of three types:
  * - an arbitrary object, or a simple type (which has been created while mapping)
  *   This is the normal case.
  * - NULL, indicating that this object should *not* be mapped
  *   (i.e. a "File Upload" Converter could return NULL if no file has been
  *   uploaded, and a silent failure should occur.
  * - An instance of \TYPO3\CMS\Extbase\Error\Error
  *   This will be a user-visible error message later on.
  * Furthermore, it should throw an Exception if an unexpected failure
  * (like a security error) occurred or a configuration issue happened.
  *
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  *
  * @return mixed|\TYPO3\CMS\Extbase\Error\Error target type, or an error object
  * @throws \TYPO3\CMS\Extbase\Property\Exception\TypeConverterException thrown in case a developer error occurred
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = [], \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
 {
     return $this->frontendUserRepository->findByUid($source);
 }
 /**
  * @test
  * @return void
  */
 public function findByMailhashReturnsUserThatShouldGetActivated()
 {
     $expected = 'testHash';
     $this->testingFramework->createAndLoginFrontEndUser('', array('tx_extbase_type' => 'TYPO3\\CMS\\Extbase\\Domain\\Model\\FrontendUser', 'mailhash' => $expected));
     $this->assertInstanceOf('Evoweb\\SfRegister\\Domain\\Model\\FrontendUser', $this->fixture->findByMailhash($expected));
 }