Commit c97efbc0 authored by Thomas Löffler's avatar Thomas Löffler

Merge branch '227-recover-process-must-set-default-group' into 'develop'

Resolve "Recover process must set default group"

Closes #227

See merge request !118
parents e9c85a80 cd916453
Pipeline #5703 passed with stages
in 5 minutes and 9 seconds
......@@ -8,6 +8,7 @@ use In2code\Femanager\Domain\Repository\UserRepository;
use T3o\T3omy\Domain\Model\OldUser;
use T3o\T3omy\Domain\Repository\OldUserRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
......@@ -75,14 +76,15 @@ class ReactivateUserHook implements \TYPO3\CMS\Backend\RecordList\RecordListGetT
public function recoverUser(OldUser $oldUser): bool
{
$userRepository = $this->objectManager->get(UserRepository::class);
$userGroupRepository = $this->objectManager->get(FrontendUserGroupRepository::class);
$random = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\Random::class);
/** @var User $frontendUser */
$frontendUser = $this->objectManager->get(User::class);
$frontendUser->setUsername($oldUser->getUsername());
$frontendUser->setEmail($oldUser->getEmail());
$frontendUser->setName($oldUser->getUsername());
$frontendUser->setPassword($random->generateRandomBytes(20));
$frontendUser->addUsergroup($userGroupRepository->findByUid(1));
$frontendUser->setPid(5);
$userRepository->add($frontendUser);
$this->persistenceManager->persistAll();
......
Markdown is supported
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