‪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 {
32  protected ‪Random ‪$random;
33 
34  public function ‪__construct()
35  {
36  $this->random = GeneralUtility::makeInstance(Random::class);
37  }
38 
44  public function ‪processDatamap_preProcessFieldArray(&$incomingFieldArray, $table, $id, ‪DataHandler $dataHandler)
45  {
46  // Not within be_users
47  if ($table !== 'be_users') {
48  return;
49  }
50  // Existing record, nothing to change
52  return;
53  }
54  if ($dataHandler->isImporting) {
55  return;
56  }
57  if (!isset($incomingFieldArray['password']) || (string)$incomingFieldArray['password'] === '') {
58  $incomingFieldArray['password'] = $this->random->generateRandomPassword([
59  'lowerCaseCharacters' => true,
60  'upperCaseCharacters' => true,
61  'digitCharacters' => true,
62  'specialCharacters' => true,
63  ]);
64  }
65  if (!isset($incomingFieldArray['username']) || (string)$incomingFieldArray['username'] === '') {
66  $incomingFieldArray['username'] = 'autogenerated-' . md5($id);
67  }
68  }
69 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:94
‪TYPO3\CMS\Core\Hooks\BackendUserPasswordCheck\$random
‪Random $random
Definition: BackendUserPasswordCheck.php:32
‪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:44
‪TYPO3\CMS\Core\Hooks\BackendUserPasswordCheck
Definition: BackendUserPasswordCheck.php:31
‪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:34
‪TYPO3\CMS\Core\Hooks
Definition: BackendUserGroupIntegrityCheck.php:18