Commit 6ab90a6f authored by Stefan Busemann's avatar Stefan Busemann
Browse files

Merge branch '165-uri-builder-fails-at-reactivate-user-process' into 'develop'

Resolve "URI Builder fails at reactivate user process"

Closes #165

See merge request !85
parents 0bc83cc8 a34b3630
Pipeline #5013 passed with stages
in 7 minutes and 1 second
<?php
declare(strict_types = 1);
namespace T3o\T3omy\Domain\Repository;
use TYPO3\CMS\Extbase\Persistence\Repository;
......@@ -11,4 +12,13 @@ use TYPO3\CMS\Extbase\Persistence\Repository;
*/
class OldUserRepository extends Repository
{
public function __construct()
{
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
parent::__construct($objectManager);
$querySettings = $objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(false);
$this->setDefaultQuerySettings($querySettings);
}
}
......@@ -39,27 +39,37 @@ class ReactivateUserHook
/**
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
*/
public function reactivateOldUser()
public function reactivateOldUser(array $params, \TYPO3\CMS\Felogin\Controller\FrontendLoginController $frontendLoginController)
{
$this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$this->persistenceManager = $this->objectManager->get(PersistenceManager::class);
$this->oldUserRepository = $this->objectManager->get(OldUserRepository::class);
// check if there is a fitting user in old user table
$username = GeneralUtility::_GP('user');
/** @var /T3o/T3omy/Domain/Model/OldUser $oldUser */
$oldUser = $this->oldUserRepository->findOneByUsername(GeneralUtility::_POST('user'));
if ($oldUser) {
if ($this->recoverUser($oldUser)) {
$this->oldUserRepository->remove($oldUser);
$this->persistenceManager->persistAll();
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class);
if ($username) {
$oldUser = $this->oldUserRepository->findOneByUsername(GeneralUtility::_POST('user'));
if ($oldUser) {
$uriBuilder = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class);
$configurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::class);
$configurationManager->setContentObject($frontendLoginController->cObj);
$uriBuilder->injectConfigurationManager($configurationManager);
$uriBuilder->initializeObject();
$uri = $uriBuilder->reset()
->setTargetPageUid(37)
->setTargetPageUid(38)
->setTargetPageType(0)
->setCreateAbsoluteUri(true)
->buildFrontendUri();
\TYPO3\CMS\Core\Utility\HttpUtility::redirect($uri, \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303);
// $frontendLoginController->LOCAL_LANG['']
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($uri);
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($frontendLoginController->LOCAL_LANG);
// if ($this->recoverUser($oldUser)) {
// $this->oldUserRepository->remove($oldUser);
// $this->persistenceManager->persistAll();
// }
}
}
}
......@@ -71,6 +81,7 @@ class ReactivateUserHook
*/
public function recoverUser(OldUser $oldUser): bool
{
return true;
$userRepository = $this->objectManager->get(UserRepository::class);
$random = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\Random::class);
......@@ -86,7 +97,7 @@ class ReactivateUserHook
$ldapOperation = $this->objectManager->get(FeManagerHooks::class);
$ldapOperation->createUser($frontendUser);
// $ldapOperation->createUser($frontendUser);
return true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment