public static function loginUser($login, $password, $authenticationMatch = false)
    {
        try {
            /** @var \Netgen\Bundle\EzSyliusBundle\Entity\AdminUser $syliusUser */
            $syliusUser = self::$userProvider->loadUserByUsername($login);
        } catch (UsernameNotFoundException $e) {
            self::loginFailed(false, $login);

            return false;
        }

        $apiUser = $syliusUser->getAPIUser();
        if (!$apiUser instanceof User) {
            self::loginFailed(false, $login);

            return false;
        }

        $encoder = self::$encoderFactory->getEncoder($syliusUser);

        // Check if login and password are legit.
        if (
            !$encoder->isPasswordValid(
                $syliusUser->getPassword(),
                $password,
                $syliusUser->getSalt()
            )
        ) {
            self::loginFailed($apiUser->getUserId(), $login);

            return false;
        }

        $user = self::fetch($apiUser->getUserId());
        if (!$user instanceof eZUser) {
            self::loginFailed($apiUser->getUserId(), $login);

            return false;
        }

        self::loginSucceeded($user);

        return $user;
    }