public static function loadUserByUsername($username)
	{
		/** @var Request $request */
		$request = System::getContainer()->get('request_stack')->getCurrentRequest();

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

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

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

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

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

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

		// Check if a passwords needs rehashing (see contao/core#8820)
		if ($isLogin)
		{
			$blnAuthenticated = password_verify($request->request->get('password'), $user->password);
			$blnNeedsRehash = password_needs_rehash($user->password, PASSWORD_DEFAULT);

			// Re-hash the password if the algorithm has changed
			if ($blnAuthenticated && $blnNeedsRehash)
			{
				$user->password = password_hash($request->request->get('password'), PASSWORD_DEFAULT);
				$user->save();
			}
		}

		$user->setUserFromDb();

		return $user;
	}
public static function loadUserByUsername($username)
	{
		/** @var Request $request */
		$request = System::getContainer()->get('request_stack')->getCurrentRequest();

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

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

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

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

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

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

		// Check if a passwords needs rehashing (see contao/core#8820)
		if ($isLogin)
		{
			$blnAuthenticated = password_verify($request->request->get('password'), $user->password);
			$blnNeedsRehash = password_needs_rehash($user->password, PASSWORD_DEFAULT);

			// Re-hash the password if the algorithm has changed
			if ($blnAuthenticated && $blnNeedsRehash)
			{
				$user->password = password_hash($request->request->get('password'), PASSWORD_DEFAULT);
				$user->save();
			}
		}

		$user->setUserFromDb();

		return $user;
	}
{@inheritdoc}

@return User