‪TYPO3CMS  ‪main
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 
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-' . md5($id);
65  }
66  }
67 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:95
‪TYPO3\CMS\Core\Hooks\BackendUserPasswordCheck\$random
‪Random $random
Definition: BackendUserPasswordCheck.php:34
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger(mixed $var)
Definition: MathUtility.php:69
‪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:31
‪TYPO3\CMS\Core\Utility\GeneralUtility\hmac
‪static string hmac($input, $additionalSecret='')
Definition: GeneralUtility.php:474
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:24
‪TYPO3\CMS\Core\Crypto\Random
Definition: Random.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Hooks\BackendUserPasswordCheck\__construct
‪__construct()
Definition: BackendUserPasswordCheck.php:36
‪TYPO3\CMS\Core\Hooks
Definition: BackendUserGroupIntegrityCheck.php:18