Fetches the user for a given username/password combination.

@param string $username username
@param string $password password

@throws AuthException when a matching user cannot be found.

@return UserInterface matching user
764452
public function getUserWithCredentials($username, $password)
    {
        if (empty($username)) {
            throw new AuthException('Please enter a valid username.');
        }

        if (empty($password)) {
            throw new AuthException('Please enter a valid password.');
        }

        // look the user up with the given username
        $usernameWhere = $this->buildUsernameWhere($username);
        $userClass = $this->auth->getUserClass();
        $user = $userClass::where($usernameWhere)
                          ->first();

        if (!$user) {
            throw new AuthException('We could not find a match for that email address and password.');
        }

        if (!$this->verifyPassword($user, $password)) {
            throw new AuthException('We could not find a match for that email address and password.');
        }

        if ($user->isTemporary()) {
            throw new AuthException('It looks like your account has not been setup yet. Please go to the sign up page to finish creating your account.');
        }

        if (!$user->isEnabled()) {
            throw new AuthException('Sorry, your account has been disabled.');
        }

        if (!$user->isVerified()) {
            throw new AuthException('You must verify your account with the email that was sent to you before you can log in.');
        }

        // success!
        return $user;
    }
849428
public function basicAuth($username, $password)
    {
        $this->username = $username;
        $this->password = $password;
        return $this;
    }
532767
public static function signIn($username , $password)
	{
		$ip = self::getClientIp();
		$ua = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
		$ts = date("U");

		if ( self::isValidPassword($username , $password) ) {

			self::sessionWrite( array( 'username' => $username ) );
			self::reload();
			self::$auth['users'][ $username ]['logincount'] = (int) @self::$auth['users'][ $username ]['logincount'] + 1;
			self::$auth['users'][ $username ]['lastlogin'] = array(
				'ip' => $ip,
				'ua' => $ua,
				'ts' => $ts
			);
			self::log( 'signin' , $username , $ts , $ip , $ua );
			self::save();

			return self::$auth['users'][ $username ];
		}

		self::log( 'signinerr' , $username , $ts , $ip , $ua );
		self::save();

		return false;
	}
1338928
public function getUserByName($username)
    {
        return $this->getUsers()->then(function (array $users) use ($username) {
            foreach ($users as $user) {
                if ($user->getUsername() === $username) {
                    return $user;
                }
            }

            throw new UserNotFoundException("The user \"$username\" does not exist.");
        });
    }
296763
public static function login($username, $password) {
		if ($user = user::find($username, $password)) {
			self::$user           = $user;
			self::$isGuest        = false;
			$_SESSION["username"] = $username;

			return true;
		}

		return false;
	}
354009
protected function checkUserPassword($username, $password)
    {
        if (!isset($this->users[$username]) || $this->users[$username] !== $password) {
            return false;
        }

        return true;
    }
319
public function login($username, $password)
	{
		$response = $this->http->get($this->getUrl('oauth2/access_token'), array(
			'grant_type'	=>	'password ',
			'username'		=>	$username,
			'password'		=>	$password,
			'client_id'		=>	$this->appid,
			'client_secret'	=>	$this->appSecret,
		));
		$this->result = $response->json(true);
		if(!isset($this->result['error_code']))
		{
			return $this->accessToken = $this->result['access_token'];
		}
		else
		{
			throw new ApiException(isset($this->result['error']) ? $this->result['error'] : '', $this->result['error_code']);
		}
	}
933669
public function setHttpAuth(string $username, string $password = ''): AbstractApi
    {
        $this->httpAuth['username'] = $username;
        $this->httpAuth['password'] = $password;

        return $this;
    }
1316698
public function withBasicAuth(?string $username = null, string $password = null): self
    {
        if ($username === null) {
            return $this->withoutHeader('Authorization');
        } else {
            $auth = base64_encode($username . ':' . $password);

            return $this->withHeader('Authorization', "Basic {$auth}");
        }
    }
304431
public static function authBasic($user, $password, $request = null)
    {
        return ($request ? $request->getBasicAuthUser() : Lb::app()->getBasicAuthUser()) == $user &&
        HashHelper::hash($request ? $request->getBasicAuthPassword() : Lb::app()->getBasicAuthPassword()) == $password;
    }
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;
    }
152303
private function getUser($username)
    {
        if (!isset($this->users[strtolower($username)])) {
            $ex = new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
            $ex->setUsername($username);

            throw $ex;
        }

        return $this->users[strtolower($username)];
    }
461905
private function fetchUser($username, $password)
    {
        if (!empty($username) && !empty($password) && is_numeric($this->userId)) {

            //Create login post data
            $data = array(
                'username' => $username,
                'password' => $password
            );

            //Json handler
            $response = new Helper\Response();

            //Make Curl
            $result = $this->curl->request('POST', rtrim(AD_INTEGRATION_URL, "/") . '/user/current', $data, 'json', array('Content-Type: application/json'));

            //Is curl error
            if(is_wp_error($result)) {
                return false; 
            }

            //Is json error
            if ($response::isJsonError($result)) {
                return false;
            }

            //Decode
            $result = json_decode($result);

            //Return result
            if (is_array($result)) {
                $result = array_pop($result);
            }

            return $result;
        }

        return false;
    }
340491
public function getPersonalToken($username, $password)
    {
        $response = $this->client->request('POST', $this->authorization_url(),
            [
                "auth" => [ $username, $password],
                "json" => $this->authorizationsRequestJson()
            ]
        );
        $response = json_decode($response->getBody());
        $this->tokenName = $response->app->name;
        return $response->token;
    }
1167448
public function authenticate($userName, $password)
    {
        $this->beforeLogin($userName, $password);
        $result = $this->adapter->authenticate($userName, $password);
        if ($result) {
            $this->profile->loadProfile("$this->userNameFieldName = '$userName'");
            $this->profile->resetToken();
        }
        $this->afterLogin($userName, $password, $result);
        return $result;
    }
867190
private static function getPasswordHash($username , $password)
	{
		return sha1( self::getSecurityToken() . $username . self::getGenerated() . $password );
	}
1210749
def get_user_by_password(self, username, password):
        
        try:
            user = self.get(username=username)
        except User.DoesNotExist:
            return None
        
        if bcrypt.hashpw(password, user.pass_hash) == user.pass_hash:
            return user
        else:
            return None