TYPO3 CMS  TYPO3_8-7
BackendUserPasswordCheck.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
4 namespace TYPO3\CMS\Core\Hooks;
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 }
processDatamap_preProcessFieldArray(&$incomingFieldArray, $table, $id, DataHandler $dataHandler)
static hmac($input, $additionalSecret='')
static makeInstance($className,... $constructorArguments)