コード例 #1
0
ファイル: Div.php プロジェクト: khanhdeux/typo3test
 /**
  * Autogenerate username and password if it's empty
  *
  * @param User $user
  * @return User $user
  */
 public function fallbackUsernameAndPassword(User $user)
 {
     $settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
     if (!$user->getUsername()) {
         $user->setUsername(self::getRandomString($settings['new']['misc']['autogenerate']['username']['length'], $settings['new']['misc']['autogenerate']['username']['addUpperCase'], $settings['new']['misc']['autogenerate']['username']['addSpecialCharacters']));
         if ($user->getEmail()) {
             $user->setUsername($user->getEmail());
         }
     }
     if (!$user->getPassword()) {
         $password = self::getRandomString($settings['new']['misc']['autogenerate']['password']['length'], $settings['new']['misc']['autogenerate']['password']['addUpperCase'], $settings['new']['misc']['autogenerate']['password']['addSpecialCharacters']);
         $user->setPassword($password);
         $user->setPasswordAutoGenerated($password);
     }
     return $user;
 }
コード例 #2
0
ファイル: UserTest.php プロジェクト: khanhdeux/typo3test
 /**
  * @test
  * @return void
  */
 public function setUsernameForStringSetsUsername()
 {
     $this->fixture->setUsername('Conceived at T3CON10');
     $this->assertSame('Conceived at T3CON10', $this->fixture->getUsername());
 }