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