Default action, displays the login screen

@param string $username Optional: A username to pre-fill into the username field
@param boolean $unauthorized
@return void
166441
public function indexAction($username = null, $unauthorized = false)
    {
        if ($this->securityContext->getInterceptedRequest() || $unauthorized) {
            $this->response->setStatus(401);
        }
        if ($this->authenticationManager->isAuthenticated()) {
            $this->redirect('index', 'Backend\Backend');
        }
        $currentDomain = $this->domainRepository->findOneByActiveRequest();
        $currentSite = $currentDomain !== null ? $currentDomain->getSite() : $this->siteRepository->findDefault();
        $this->view->assignMultiple([
            'styles' => array_filter($this->settings['userInterface']['backendLoginForm']['stylesheets']),
            'username' => $username,
            'site' => $currentSite
        ]);
    }
1328835
public function setUsername($username = '')
    {
        $this->username = $username;
        $this->_debug->info(__FUNCTION__, 'setUsername: ', $this->username);
    }
620286
public function logIn($username,$password) {
		session_regenerate_id(true);
		$sql = "SELECT id,password FROM {$this->primaryTable} WHERE username=:username AND inactive=0";
		if ($result = $this->executeQuery($sql,array(":username"=>$username))) {
			if (password_verify($password,$result[0]['password'])) {
				$this->setSessionUserId($result[0]['id']);
				return true;			
			}
		}
		return false;
	}
1348068
protected function authenticateOnServer($authUrl, $username, $password)
    {
        $response = $this->sendDigestAuthentication($authUrl, $username, $password);

        $httpCode = $response->getHttpCode();

        // If status code is not 200, something went wrong
        if (200 !== $httpCode) {
            throw new \Exception('Response with Status Code [' . $httpCode . '].', 500);
        }
    }
1056693
public function verify(string $username = null, string $password = null, string $user = null)
    {
        if ($username && $password) {
            $users = $this->getUsers($user);

            foreach ($users as $user => $credentials) {
                if (
                    password_verify($username, reset($credentials)) &&
                    password_verify($password, end($credentials))
                ) {
                    $this->currentUser = $user;

                    return;
                }
            }
        }

        throw new UnauthorizedHttpException('Basic');
    }
564640
public function login($username = 'anonymous', $password = '')
    {
        $result = @ftp_login($this->connection, $username, $password);

        if ($result === false) {
            throw new Exception('Login incorrect');
        } else {
            // set passive mode
            if (!is_null($this->passive)) {
                $this->passive($this->passive);
            }

            return $this;
        }
    }
413800
public function deactivate($username)
    {
        $user = $this->findUserByUsernameOrThrowException($username);
        $user->setEnabled(false);
        $this->userManager->updateUser($user);

        $event = new UserEvent($user, $this->getRequest());
        $this->dispatcher->dispatch(Events::USER_DEACTIVATED, $event);
    }
1082597
public function login($username, $email)
    {
        $password = $this->createPassword($username);
        $token = $this->getToken($username, $password);

        if (empty($token)) {
            $this->signup($username, $password, $email);
            $token = $this->getToken($username, $password);
        }

        $this->setRememberMeCookie($token);
    }
550291
public function setAuthorization($username, $password)
    {
        $this->username = $username;
        $this->password = $password;

        return $this;
    }
1256506
function user_login($username, $password) {
        global $CFG, $DB;

        if ($this->is_configured() === false) {
            debugging(get_string('auth_notconfigured', 'auth', $this->authtype));
            return false;
        }

        $extusername = core_text::convert($username, 'utf-8', $this->config->extencoding);
        $extpassword = core_text::convert($password, 'utf-8', $this->config->extencoding);

        if ($this->is_internal()) {
            // Lookup username externally, but resolve
            // password locally -- to support backend that
            // don't track passwords.

            if (isset($this->config->removeuser) and $this->config->removeuser == AUTH_REMOVEUSER_KEEP) {
                // No need to connect to external database in this case because users are never removed and we verify password locally.
                if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id, 'auth'=>$this->authtype))) {
                    return validate_internal_user_password($user, $password);
                } else {
                    return false;
                }
            }

            $authdb = $this->db_init();

            $rs = $authdb->Execute("SELECT *
                                      FROM {$this->config->table}
                                     WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'");
            if (!$rs) {
                $authdb->Close();
                debugging(get_string('auth_dbcantconnect','auth_db'));
                return false;
            }

            if (!$rs->EOF) {
                $rs->Close();
                $authdb->Close();
                // User exists externally - check username/password internally.
                if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id, 'auth'=>$this->authtype))) {
                    return validate_internal_user_password($user, $password);
                }
            } else {
                $rs->Close();
                $authdb->Close();
                // User does not exist externally.
                return false;
            }

        } else {
            // Normal case: use external db for both usernames and passwords.

            $authdb = $this->db_init();

            $rs = $authdb->Execute("SELECT {$this->config->fieldpass}
                                      FROM {$this->config->table}
                                     WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'");
            if (!$rs) {
                $authdb->Close();
                debugging(get_string('auth_dbcantconnect','auth_db'));
                return false;
            }

            if ($rs->EOF) {
                $authdb->Close();
                return false;
            }

            $fields = array_change_key_case($rs->fields, CASE_LOWER);
            $fromdb = $fields[strtolower($this->config->fieldpass)];
            $rs->Close();
            $authdb->Close();

            if ($this->config->passtype === 'plaintext') {
                return ($fromdb == $extpassword);
            } else if ($this->config->passtype === 'md5') {
                return (strtolower($fromdb) == md5($extpassword));
            } else if ($this->config->passtype === 'sha1') {
                return (strtolower($fromdb) == sha1($extpassword));
            } else if ($this->config->passtype === 'saltedcrypt') {
                return password_verify($extpassword, $fromdb);
            } else {
                return false;
            }

        }
    }
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()
            );
        }
    }
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;
	}
1245505
public function loadUserByUsername($username)
    {
        if (null === $user = $this->findOneBy(array('_login' => $username))) {
            throw new UsernameNotFoundException(sprintf('Unknown username `%s`.', $username));
        }

        return $this->checkActivatedStatus($user);
    }
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);
        }
    }
424174
public static function logIn($username, $password)
    {
        if (!$username)
        {
            throw new AVException("Cannot log in user with an empty name");
        }
        if (!$password)
        {
            throw new AVException("Cannot log in user with an empty password.");
        }
        $data = array("username" => $username, "password" => $password);
        $result = AVClient::_request("GET", "/login", "", $data);
        $user = new AVUser();
        $user->_mergeAfterFetch($result);
        $user->handleSaveResult(true);
        AVClient::getStorage()->set("user", $user);

        return $user;
    }
366758
public function login($username, $password, $remember = 1)
	{
		$event = new Event('onPlatformLogin');
		$event->addArgument('username', $username);
		$event->addArgument('password', $password);
		$event->addArgument('remember', $remember);
		$event->addArgument('activePlugin', $this->activePlugin);

		Factory::getDispatcher()->triggerEvent($event);
	}
1098845
public function setAuth($username = null, $password = null)
    {
        $this->username = $username;
        $this->password = $password;
    }