Fills the user_login field of the login form with a given username.

@param string $username the username to fill into the login form

@throws \Behat\Mink\Exception\ExpectationException
481788
public function setUserName(string $username)
    {

        // Get the session.
        $session = $this->verifySession();

        // Verify we are on the login page.
        $this->verifyLoginPage();

        // Get the page.
        $page = $session->getPage();

        // Find the user_login field.
        $user_login_field = $page->find('css', '#user_login');

        // Try to focus the user_login field.
        try {
            $user_login_field->focus();
        } catch (UnsupportedDriverActionException $e) {
            // This will fail for GoutteDriver but neither is it necessary.
        }

        // Set the value of $username in the user_login field.
        $user_login_field->setValue($username);
        // The field can be stubborn, so we use fillField also.
        $page->fillField('user_login', $username);

        // Attempt to fill the user_login field with JavaScript.
        try {
            $session->executeScript(
                "document.getElementById('user_login').value='$username'"
            );
        } catch (UnsupportedDriverActionException $e) {
            // This will fail for drivers without JavaScript support
        }

        // Get the actual value of the user_login field.
        $username_actual = $user_login_field->getValue();

        // Verify the username was filled in correctly.
        if ($username_actual !== $username) {
            throw new ExpectationException(
                sprintf(
                    'Expected the username field to be "%1$s", found "%2$s".',
                    $username,
                    $$username_actual
                ),
                $this->getDriver()
            );
        }
    }
1242301
public function loadUserByUsername($username)
    {
        /** @var User|UserInterface $user */
        $user = $this->getRepository()->findOneBy(['username' => $username]);
        if (!$user && $this->allowEmailAsUsername) {
            $user = $this->getRepository()->findOneBy(['email' => $username]);
        }
        if ($user) {
            return $user;
        }

        throw new UsernameNotFoundException($username);
    }
346747
public function authenticateUser($username)
    {
        if ($username)
        {
            $user = $this->userManager->findUserBy(['username' => $username]);

            if ($user)
            {
                $usernamePasswordToken = new UsernamePasswordToken($user->getUsername(), $user->getPlainPassword(), 'default', $user->getRoles());
                $this->tokenStorage->setToken($usernamePasswordToken);

                return $user;
            }
        }
        return false;
    }
29750
public function setUser($username)
    {
        $app = App::getInstance();

        try {
            parent::__construct($username);
        } catch (\FelixOnline\Exceptions\ModelNotFoundException $e) {
            User::createUser($username);
            parent::__construct($username);
        }

        $user = new User($username);
        $this->logIn($user);
        $this->user = $user;
    }
876269
protected function _loginUser($username, $data = array())
    {
        $data['username'] = $username;

        $parameter        = JFactory::getApplication()->isAdmin() ? 'admin_language' : 'language';
        $data['language'] = $this->getObject('user.provider')->load($username)->get($parameter);

        $options = $this->_options;

        JPluginHelper::importPlugin('user');
        $results = JFactory::getApplication()->triggerEvent('onUserLogin', array($data, $options));

        // The user is successfully logged in. Refresh the current user.
        if (in_array(false, $results, true) == false)
        {
            parent::_loginUser($username);
            return true;
        }

        return false;
    }
1233783
def fill_login_form(self, username, username_field, user_password,
                        user_password_field):
        
        self.fill_form_field(username_field, username)  # set username
        self.fill_form_field(user_password_field, user_password)
867572
public function setUsername($username){
        if(!$this->setModified('username', $username)->isModified()){
            return $this;
        }
        $this->username = $username;

        return $this;
    }
450785
public function theUsernameShouldBe(string $username)
    {
        $toolbar = $this->getElement('Toolbar');
        $actual  = $toolbar->getAuthenticatedUserText();

        if ($username !== $actual) {
            $message = sprintf('[W807] Toolbar shows authenticated user is "%1$s", not "%2$s"', $actual, $username);
            throw new ElementTextException($message, $this->getSession()->getDriver(), $toolbar);
        }
    }
1176263
public function validateUserName($userName)
    {
        if (empty($userName)) {
            $this->addError('userName', 'User name cannot be empty');
            return false;
        }

        if (!is_string($userName)) {
            $this->addError('userName', 'User name must be a string');
            return false;
        }

        if (mb_strlen($userName, 'UTF-8') > 255) {
            $this->addError('userName', 'User name length has to be less or equal to 255');
            return false;
        }


        return true;
    }
232730
public function logIn(string $username, string $password, string $redirect_to = '/')
    {
        if ($this->loggedIn()) {
            $this->logOut();
        }

        // Start a session.
        $session = $this->getSession();

        // Go to the login form.
        $this->visitPath('wp-login.php?redirect_to=' . urlencode($this->locatePath($redirect_to)));

        // Fill in username.
        $this->login_page->setUserName($username);

        // Fill in password.
        $this->login_page->setUserPassword($password);

        // Submit the login form.
        $this->login_page->submitLoginForm();

        if (! $this->loggedIn()) {
            throw new ExpectationException('[W803] The user could not be logged-in.', $this->getSession()->getDriver());
        }
    }
52213
private void loadUser(String username)
    {
        try
        {
            if (null==_con)
                connectDatabase();
            
            if (null==_con)
                throw new SQLException("Can't connect to database");
            
            PreparedStatement stat = _con.prepareStatement(_userSql);
            stat.setObject(1, username);
            ResultSet rs = stat.executeQuery();
    
            if (rs.next())
            {
                Object key = rs.getObject(_userTableKey);
                put(username, rs.getString(_userTablePasswordField));
                stat.close();
                
                stat = _con.prepareStatement(_roleSql);
                stat.setObject(1, key);
                rs = stat.executeQuery();

                while (rs.next())
                    addUserToRole(username, rs.getString(_roleTableRoleField));
                
                stat.close();
            }
        }
        catch (SQLException e)
        {
            log.warn("UserRealm " + getName()
                      + " could not load user information from database", e);
            connectDatabase();
        }
    }
1158454
public function iHaveUser($username)
    {
        $email = $this->findNonExistingUserEmail($username);
        $password = $username;
        $user = $this->ensureUserExists($username, $email, $password);
    }
265118
public function setUsername(string $username): void
	{
		if (Strings::match($username, '/[^A-Za-z0-9_]/')) {
			throw new InvalidArgumentException('Username contains invalid characters');
		}

		/* @var $repository UsersRepository */
		$repository = $this->getRepository();
		$user = $repository->getByUsername($username);
		if ($user !== null && $user !== $this) {
			throw new UniqueConstraintViolationException("Username '$username' exists");
		}
		$this->username = $username;
	}
228898
public function setAuth($username, $password)
    {
        if (!empty($username) && !empty($password)) {
            $this->username = stripslashes(trim($username));
            $this->password = stripslashes(trim($password));
        }
    }
1144977
private function _login($username, $password) {
        $data["Envelope"] = array(
            "Body" => array(
                "Login" => array(
                    "USERNAME" => $username,
                    "PASSWORD" => $password,
                ),
            ),
        );
        $response = $this->_request($data);
        $result = $response["Envelope"]["Body"]["RESULT"];
        if ($this->_isSuccess($result)) {
            $this->_jsessionid = $result['SESSIONID'];
            $this->_session_encoding = $result['SESSION_ENCODING'];
            $this->_username = $username;
            $this->_password = $password;
        } else {
            throw new \Exception("Login Error: ".$this->_getErrorFromResponse($response));
        }
    }
507443
public function basic(string $username, string $password)
    {
        $this->type = self::BASIC;
        $this->username = $username;
        $this->password = $password;
    }
1277039
public function setUsername($username)
    {
        if (preg_match(self::PATTERN_MATCH_USERNAME, $username) !== 1) {
            throw new \InvalidArgumentException('"' . $username . '" is not a valid username.', 1184071238);
        }

        $this->username = $username;
    }