/** * 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; }
/** * Remove an image from user object and request object * * @param \Evoweb\SfRegister\Domain\Model\FrontendUser $user * @param string $removeImage * @return \Evoweb\SfRegister\Domain\Model\FrontendUser */ protected function removeImageFromUserAndRequest(\Evoweb\SfRegister\Domain\Model\FrontendUser $user, $removeImage) { if ($user->getUid() !== null) { $localUser = $this->userRepository->findByUid($user->getUid()); $localUser->removeImage($removeImage); $this->userRepository->update($localUser); $this->persistAll(); } $user->removeImage($removeImage); $requestUser = $this->request->getArgument('user'); $requestUser['image'] = $user->getImage(); $this->request->setArgument('user', $requestUser); return $user; }
/** * 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); }