Skip to content

Commit

Permalink
CS
Browse files Browse the repository at this point in the history
  • Loading branch information
bytehead committed Nov 12, 2021
1 parent b579d28 commit 2b2297f
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions core-bundle/src/Resources/contao/library/Contao/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,64 +453,64 @@ public function getRoles()

/**
* @return User
*
* @deprecated Deprecated since Contao 4.13, to be removed in Contao 5.0.
*
* @deprecated Deprecated since Contao 4.13, to be removed in Contao 5.0.
*/
public static function loadUserByUsername($username)
{
trigger_deprecation('contao/core-bundle', '4.13', 'Using "Contao\User::loadUserByUsername()" has been deprecated and will no longer work in Contao 5.0. Use Contao\User::loadUserByIdentifier() instead.');
trigger_deprecation('contao/core-bundle', '4.13', 'Using "Contao\User::loadUserByUsername()" has been deprecated and will no longer work in Contao 5.0. Use Contao\User::loadUserByIdentifier() instead.');

return self::loadUserByIdentifier($username);
}

public static function loadUserByIdentifier(string $identifier): ?self
{
/** @var Request $request */
$request = System::getContainer()->get('request_stack')->getCurrentRequest();
public static function loadUserByIdentifier(string $identifier): ?self
{
/** @var Request $request */
$request = System::getContainer()->get('request_stack')->getCurrentRequest();

if ($request === null)
{
return null;
}
if ($request === null)
{
return null;
}

$user = new static();
$isLogin = $request->request->has('password') && $request->isMethod(Request::METHOD_POST);
$user = new static();
$isLogin = $request->request->has('password') && $request->isMethod(Request::METHOD_POST);

// Load the user object
if ($user->findBy('username', $identifier) === false)
{
// Return if its not a real login attempt
if (!$isLogin)
{
return null;
}
// Load the user object
if ($user->findBy('username', $identifier) === false)
{
// Return if its not a real login attempt
if (!$isLogin)
{
return null;
}

$password = $request->request->get('password');
$password = $request->request->get('password');

if (self::triggerImportUserHook($identifier, $password, $user->strTable) === false)
{
return null;
}
if (self::triggerImportUserHook($identifier, $password, $user->strTable) === false)
{
return null;
}

if ($user->findBy('username', Input::post('username')) === false)
{
return null;
}
}
if ($user->findBy('username', Input::post('username')) === false)
{
return null;
}
}

$user->setUserFromDb();
$user->setUserFromDb();

return $user;
}
return $user;
}

/**
* {@inheritdoc}
*
* @deprecated Deprecated since Contao 4.13, to be removed in Contao 5.0.
*
* @deprecated Deprecated since Contao 4.13, to be removed in Contao 5.0.
*/
public function getUsername()
{
trigger_deprecation('contao/core-bundle', '4.13', 'Using "Contao\User::getUsername()" has been deprecated and will no longer work in Contao 5.0. Use Contao\User::getUserIdentifier() instead.');
trigger_deprecation('contao/core-bundle', '4.13', 'Using "Contao\User::getUsername()" has been deprecated and will no longer work in Contao 5.0. Use Contao\User::getUserIdentifier() instead.');

return $this->getUserIdentifier();
}
Expand Down

0 comments on commit 2b2297f

Please sign in to comment.