Return how many attemps are left for incorrect password.

@param string $userName

@return int Number of attempts with same user.
498205
public function getAttemptsLeftWithSameUser(string $userName): int
    {
        $attemptsLeft = ((int) $this->maxAttemptsForUserName) - $this->enhancedAuthenticationMapper->fetchAttemptsWithSameUser($userName, $this->banTimeInSeconds);

        return \max(0, $attemptsLeft);
    }
311341
public function check($password)
    {
        $hashedPassword = strtoupper(sha1($password));
        $checkHash = substr($hashedPassword, 0, 5);

        try {
            $response = $this->client->sendRequest(new Request('GET', 'https://api.pwnedpasswords.com/range/'.$checkHash));
            if ($response->getStatusCode() === 200) {
                $rowResults = explode("\n", (string) $response->getBody());
                $searchHash = substr($hashedPassword, 5);
                foreach ($rowResults as $result) {
                    if (strpos($result, $searchHash) !== false) {
                        $res = explode(':', $result);

                        return new Result(trim($res[1]));
                    }
                }
            }
        } catch (HttpException $exception) {
            $this->logger->error('HTTP Exception: '.$exception->getMessage());
        } catch (HttpException2 $exception) {
            $this->logger->error('HTTP Exception: '.$exception->getMessage());
        } catch (\Exception $exception) {
            $this->logger->error('Exception: '.$exception->getMessage());
        }

        return new Result(0);
    }
335496
public function checkUser($username = null)
  {
    if($username === null)
    {
      $username = $this->user;
    }

    if(strlen($username) == 0)
    {
      return TRUE;
    }

    $pattern = "/^(" . $this->regex["alphanum"]  . "|" . $this->regex["mark"] . "|" . $this->regex["escaped"] . "|[;:&=+$,])+$/";
    $status = @preg_match($pattern, $username);

    if($status === FALSE)
    {
      throw new TeamSpeak3_Helper_Exception("URI username validation failed");
    }

    return ($status == 1);
  }
978790
public static function isValidPassword($username , $password)
	{
		if ( ! self::userExists( $username ) ) return false;
		$compute = self::getPasswordHash($username , $password);

		return ( $compute === self::$auth['users'][$username]['pwd'] );
	}
700224
public function checkFollowingUser(string $username): bool
    {
        $this->getApi()->request($this->getApi()->sprintf('/user/following/:username', $username));

        if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
            return true;
        }

        return false;
    }
388078
private static function myValidateUsername(string $username, ?string &$error = null): bool
    {
        if ($username === '') {
            $error = 'Username "" is empty.';

            return false;
        }

        if (strpos($username, '..') !== false) {
            $error = 'Username "' . $username . '" contains "..".';

            return false;
        }

        if (strlen($username) > 64) {
            $error = 'Username "' . $username . '" is too long: Maximum length is 64.';

            return false;
        }

        if (preg_match('/[^0-9a-zA-Z.!#$%&\'*+\/=?^_`{|}~-]/', $username, $matches)) {
            $error = 'Username "' . $username . '" contains invalid character "' . $matches[0] . '".';

            return false;
        }

        return true;
    }
227128
function password_expire($username) {
        $result = 0;

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

        $ldapconnection = $this->ldap_connect();
        $user_dn = $this->ldap_find_userdn($ldapconnection, $extusername);
        $search_attribs = array($this->config->expireattr);
        $sr = ldap_read($ldapconnection, $user_dn, '(objectClass=*)', $search_attribs);
        if ($sr)  {
            $info = ldap_get_entries_moodle($ldapconnection, $sr);
            if (!empty ($info)) {
                $info = $info[0];
                if (isset($info[$this->config->expireattr][0])) {
                    $expiretime = $this->ldap_expirationtime2unix($info[$this->config->expireattr][0], $ldapconnection, $user_dn);
                    if ($expiretime != 0) {
                        $now = time();
                        if ($expiretime > $now) {
                            $result = ceil(($expiretime - $now) / DAYSECS);
                        } else {
                            $result = floor(($expiretime - $now) / DAYSECS);
                        }
                    }
                }
            }
        } else {
            error_log($this->errorlogtag.get_string('didtfindexpiretime', 'auth_ldap'));
        }

        return $result;
    }
742296
public function login(?string $username, ?string $password)
    {
        try {
            $this->startBrokerSession();

            if (!$username || !$password) {
                $this->fail('No username and/or password provided.');
            }

            if (!$this->authenticate($username, $password)) {
                $this->fail('User authentication failed.');
            }
        } catch (SSOServerException $e) {
            return $this->returnJson(['error' => $e->getMessage()]);
        }

        $this->setSessionData('sso_user', $username);

        return $this->userInfo();
    }
1210947
final protected function _validateLength() {
        //validate that required indices exist
        if (!isset($this->_userProfile['username'])
            || !isset($this->_userProfile['password'])
            || !isset($this->_userProfile['fullname'])
            || !isset($this->_userProfile['passhist'])
        ) {
            throw new UserCredentialException('The username and password are not set', 1016);
        }

        //determine which entropy to use (base or udf)
        $entropyObj = $this->_udfEntropySetting;
        
        //perform length check
        if (strlen($this->_userProfile['password']) < $entropyObj['min_pass_len']) {
            throw new UserCredentialException('The password does not meet required length. '.$this->_getPasswordLengthDescription(), \USERCREDENTIAL_ACCOUNTPOLICY_WEAKPASSWD);
        }
        
        return true;
    }
778283
public function checkAccountStatus($username)
    {
        $statusCodes = [
            0 => 'UNVERIFIED',
            1 => 'VERIFIED',
            2 => 'CERTIFIED',
            3 => 'CERTIFIED_PREMIUM',
        ];

        if (false !== ($response = $this->request('api/CekStatus.php', ['user' => $username]))) {
            return $statusCodes[ $response[ 'StatusUser' ] ];
        }

        return false;
    }
300638
public function getUserToken(string $userName) : string {
        if (isset($this->userToken[$userName])) {
            return $this->userToken[$userName];
        }
    }
404406
public function checkUserCredentials($username, $password)
    {
        $this->user = $this->app['auth']->getUserWithCredentials($username, $password);

        return $this->user instanceof User;
    }
590309
public function checkUserIsACollaborator(string $username): bool
    {
        $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/collaborators/:username',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $username));

        if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
            return true;
        }

        return false;
    }
277073
public function checkUserCredentials($username, $password)
    {
        $userDetails = $this->getUserDetails($username);

        return $userDetails && $userDetails['password'] && $userDetails['password'] === $password;
    }
371013
public static function isUser(string $username): bool {
		$userdbname = setup::getValidation("username");
		if (R::findOne('user', ' ' . $userdbname . ' = ? ', [$username])) {
			return true;
		}

		return false;
	}
32043
public function delete($username): bool
    {
        $user = $this->load($username);

        $exists = $user->exists();
        if ($exists) {
            $user->delete();
        }

        return $exists;
    }
70477
public function getDigestHash($realm, $username)
    {
        return isset($this->users[$realm.':'.$username]) ? $this->users[$realm.':'.$username] : false;
    }