‪TYPO3CMS  10.4
BackendUserPasswordCheck.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 namespace ‪TYPO3\CMS\Core\Hooks;
19 
24 
31 {
35  protected ‪$random;
36 
37  public function ‪__construct()
38  {
39  $this->random = GeneralUtility::makeInstance(Random::class);
40  }
41 
48  public function ‪processDatamap_preProcessFieldArray(&$incomingFieldArray, $table, $id, ‪DataHandler $dataHandler)
49  {
50  // Not within be_users
51  if ($table !== 'be_users') {
52  return;
53  }
54  // Existing record, nothing to change
56  return;
57  }
58  if ($dataHandler->isImporting) {
59  return;
60  }
61  if (!isset($incomingFieldArray['password']) || (string)$incomingFieldArray['password'] === '') {
62  $incomingFieldArray['password'] = GeneralUtility::hmac($id, $this->random->generateRandomBytes(20));
63  }
64  if (!isset($incomingFieldArray['username']) || (string)$incomingFieldArray['username'] === '') {
65  $incomingFieldArray['username'] = 'autogenerated-' . GeneralUtility::shortMD5($id);
66  }
67  }
68 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:84
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger($var)
Definition: MathUtility.php:74
‪TYPO3\CMS\Core\Hooks\BackendUserPasswordCheck\$random
‪Random $random
Definition: BackendUserPasswordCheck.php:34
‪TYPO3\CMS\Core\Hooks\BackendUserPasswordCheck\processDatamap_preProcessFieldArray
‪processDatamap_preProcessFieldArray(&$incomingFieldArray, $table, $id, DataHandler $dataHandler)
Definition: BackendUserPasswordCheck.php:47
‪TYPO3\CMS\Core\Hooks\BackendUserPasswordCheck
Definition: BackendUserPasswordCheck.php:31
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:22
‪TYPO3\CMS\Core\Crypto\Random
Definition: Random.php:24
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Hooks\BackendUserPasswordCheck\__construct
‪__construct()
Definition: BackendUserPasswordCheck.php:36
‪TYPO3\CMS\Core\Hooks
Definition: BackendUserGroupIntegrityCheck.php:16