Login

@param string $username
@param string $password
@return bool
@access public
762952
function login($username)
    {
        $args = func_get_args();
        if (!call_user_func_array(array(&$this, '_login'), $args)) {
            return false;
        }

        $this->window_size_server_to_client[self::CHANNEL] = $this->window_size;

        $packet = pack(
            'CNa*N3',
            NET_SSH2_MSG_CHANNEL_OPEN,
            strlen('session'),
            'session',
            self::CHANNEL,
            $this->window_size,
            0x4000
        );

        if (!$this->_send_binary_packet($packet)) {
            return false;
        }

        $this->channel_status[self::CHANNEL] = NET_SSH2_MSG_CHANNEL_OPEN;

        $response = $this->_get_channel_packet(self::CHANNEL, true);
        if ($response === false) {
            return false;
        }

        $packet = pack(
            'CNNa*CNa*',
            NET_SSH2_MSG_CHANNEL_REQUEST,
            $this->server_channels[self::CHANNEL],
            strlen('subsystem'),
            'subsystem',
            1,
            strlen('sftp'),
            'sftp'
        );
        if (!$this->_send_binary_packet($packet)) {
            return false;
        }

        $this->channel_status[self::CHANNEL] = NET_SSH2_MSG_CHANNEL_REQUEST;

        $response = $this->_get_channel_packet(self::CHANNEL, true);
        if ($response === false) {
            // from PuTTY's psftp.exe
            $command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n" .
                       "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n" .
                       "exec sftp-server";
            // we don't do $this->exec($command, false) because exec() operates on a different channel and plus the SSH_MSG_CHANNEL_OPEN that exec() does
            // is redundant
            $packet = pack(
                'CNNa*CNa*',
                NET_SSH2_MSG_CHANNEL_REQUEST,
                $this->server_channels[self::CHANNEL],
                strlen('exec'),
                'exec',
                1,
                strlen($command),
                $command
            );
            if (!$this->_send_binary_packet($packet)) {
                return false;
            }

            $this->channel_status[self::CHANNEL] = NET_SSH2_MSG_CHANNEL_REQUEST;

            $response = $this->_get_channel_packet(self::CHANNEL, true);
            if ($response === false) {
                return false;
            }
        }

        $this->channel_status[self::CHANNEL] = NET_SSH2_MSG_CHANNEL_DATA;

        if (!$this->_send_sftp_packet(NET_SFTP_INIT, "\0\0\0\3")) {
            return false;
        }

        $response = $this->_get_sftp_packet();
        if ($this->packet_type != NET_SFTP_VERSION) {
            user_error('Expected SSH_FXP_VERSION');
            return false;
        }

        if (strlen($response) < 4) {
            return false;
        }
        extract(unpack('Nversion', $this->_string_shift($response, 4)));
        $this->version = $version;
        while (!empty($response)) {
            if (strlen($response) < 4) {
                return false;
            }
            extract(unpack('Nlength', $this->_string_shift($response, 4)));
            $key = $this->_string_shift($response, $length);
            if (strlen($response) < 4) {
                return false;
            }
            extract(unpack('Nlength', $this->_string_shift($response, 4)));
            $value = $this->_string_shift($response, $length);
            $this->extensions[$key] = $value;
        }

        /*
         SFTPv4+ defines a 'newline' extension.  SFTPv3 seems to have unofficial support for it via 'newline@vandyke.com',
         however, I'm not sure what 'newline@vandyke.com' is supposed to do (the fact that it's unofficial means that it's
         not in the official SFTPv3 specs) and 'newline@vandyke.com' / 'newline' are likely not drop-in substitutes for
         one another due to the fact that 'newline' comes with a SSH_FXF_TEXT bitmask whereas it seems unlikely that
         'newline@vandyke.com' would.
        */
        /*
        if (isset($this->extensions['newline@vandyke.com'])) {
            $this->extensions['newline'] = $this->extensions['newline@vandyke.com'];
            unset($this->extensions['newline@vandyke.com']);
        }
        */

        $this->request_id = 1;

        /*
         A Note on SFTPv4/5/6 support:
         <http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-5.1> states the following:

         "If the client wishes to interoperate with servers that support noncontiguous version
          numbers it SHOULD send '3'"

         Given that the server only sends its version number after the client has already done so, the above
         seems to be suggesting that v3 should be the default version.  This makes sense given that v3 is the
         most popular.

         <http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-5.5> states the following;

         "If the server did not send the "versions" extension, or the version-from-list was not included, the
          server MAY send a status response describing the failure, but MUST then close the channel without
          processing any further requests."

         So what do you do if you have a client whose initial SSH_FXP_INIT packet says it implements v3 and
         a server whose initial SSH_FXP_VERSION reply says it implements v4 and only v4?  If it only implements
         v4, the "versions" extension is likely not going to have been sent so version re-negotiation as discussed
         in draft-ietf-secsh-filexfer-13 would be quite impossible.  As such, what \phpseclib\Net\SFTP would do is close the
         channel and reopen it with a new and updated SSH_FXP_INIT packet.
        */
        switch ($this->version) {
            case 2:
            case 3:
                break;
            default:
                return false;
        }

        $this->pwd = $this->_realpath('.');

        $this->_update_stat_cache($this->pwd, array());

        return true;
    }
776167
public function login(string $login, string $password)
    {
        $user = $this->auth_repository->login($login, $password);

        if (null === $user) {
            return null;
        }

        if ($this->container->has('user')) {
            unset($this->container['user']);
        }
        $this->container['user'] = $user;

        return $this->auth_storage->setUser($user);
    }
771261
public function login(User $user, $password)
    {
        if ($user->isPasswordValid($password)) {
            $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
            $this->tokenStorage->setToken($token);
            $user->setLastLogin(new \DateTime());
            $this->save($user);

            return true;
        }

        return false;
    }
490428
public function connect($username, $password)
    {
        $error = parent::connect($username, $password);

        if ($error) {
            return $error;
        }

        return $this->load_script();
    }
1238204
public function login($username, $password)
    {
        $data = $this->matrix()->request('POST', $this->endpoint('login'), [
            'type' => 'm.login.password',
            'user' => $username,
            'password' => $password
        ]);
        $this->setData($data);
        return $this->data;
    }
694869
public function basicAuth($username, $password)
    {
        $this->auth = new BasicAuth($username, $password);
        return $this->auth;
    }
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']);
		}
	}
1119318
public function login($username, $password)
    {
        $model       = $this->slice->getRequired('model');
        $loginFields = $this->slice->getRequired('loginFields');
        $hashField   = $this->slice->getRequired('hashField');

        $userQuery = $this->provider->auth()->orm()->repository($model);

        foreach ($loginFields as $field)
        {
            $userQuery->whereOr($field, $username);
        }

        $user = $userQuery->findOne();

        if ($user && $this->verify($password, $user->get($hashField)))
        {
            $this->provider->setUser($user);
        }

        return $user;
    }
1246221
public function login($username_or_email = '', $password = '')
	{
		if ( ! ($this->user = $this->validate_user($username_or_email, $password)))
		{
			// force a logout
			$this->logout();

			// and signal a failed login
			return false;
		}

		// register so Auth::logout() can find us
		Auth::_register_verified($this);

		// store the logged-in user and it's hash in the session
		\Session::set('username', $this->user->username);
		\Session::set('login_hash', $this->create_login_hash());

		// and rotate the session id, we've elevated rights
		\Session::instance()->rotate();

		return true;
	}
1205578
public function authenticate($login, $password)
    {
        if (!isset($this->server['PHP_AUTH_USER'])) {
            $this->forbid();
            return false;
        } else {
            if (($this->server['PHP_AUTH_USER'] == $login) && ($this->server['PHP_AUTH_PW'] == $password)) {
                return true;
            } else {
                $this->forbid();
                return false;
            }
        }
    }
761506
public function checkUserCredentials($username, $password)
    {
        if ($user = $this->getUser($username)) {
            return $this->checkPassword($user, $password);
        }

        return false;
    }
76948
public function login($userName, $password, AccessControlEvent $event)
    {
        $authCookie = $this->requestStack->getCurrentRequest()->cookies->get($this->authTokenName);

        // Remove expired tokens
        $this->getRepositoryAuthtoken()->deleteExpiredTokens();

        if ($userName !== null && $password !== null) {
            return $this->loginCheckUser($userName, $password, $event);
        } elseif ($authCookie !== null) {
            return $this->loginCheckAuthtoken($authCookie, $event);
        }

        $this->systemLogger->error('Login function called with empty username/password combination, or no authentication token.', ['event' => 'security']);
        throw new AccessControlException('Invalid login parameters.');
    }
669075
function user_password($username,$password){
        if ($username==NULL){ return (false); }
        if ($password==NULL){ return (false); }
        if (!$this->_bind){ return (false); }
        if (!$this->_use_ssl){ echo ("FATAL: SSL must be configured on your webserver and enabled in the class to set passwords."); exit(); }
        
        $user=$this->user_info($username,array("cn"));
        if ($user[0]["dn"]==NULL){ return (false); }
        $user_dn=$user[0]["dn"];
                
        $add=array();
        $add["unicodePwd"][0]=$this->encode_password($password);
        
        $result=ldap_mod_replace($this->_conn,$user_dn,$add);
        if ($result==false){ return (false); }
        
        return (true);
    }
1346681
public function login($login, $password)
    {
        $this->_db->query(
            'SELECT * FROM '.$this->_dbConfig['table']
            .' WHERE '.$this->_dbConfig['login'].' = :lg 
               AND '.$this->_dbConfig['password'].' = :pw',
            [':lg'=>$login, ':pw'=>$password]
        );

        $row = $this->_db->result();
        if (isset($row[0])) {
            $row = $row[0]->getAll();

            foreach ($this->_data as $i => $d) {
                if (isset($row[$this->_dbConfig[$i]])) {
                    $this->_data[$i] = $row[$this->_dbConfig[$i]];
                }
            }
            $this->_login = true;
            return true;
        }
        $this->_login = false;
        return false;
    }
354009
protected function checkUserPassword($username, $password)
    {
        if (!isset($this->users[$username]) || $this->users[$username] !== $password) {
            return false;
        }

        return true;
    }
77044
public function useBasicAuth($username=false, $password=false) {
        self::$useBasicAuth=($username!==false && $password!==false);
        self::$username=$username;
        self::$password=$password;
    }
1286691
public function stateless($username, $password)
    {
        $user = $this->sentinel->stateless(
            [
                'email'    => $username,
                'password' => $password,
            ]
        );

        if ( ! ($user instanceof CartalystUserInterface)) {
            return false;
        }

        // This is still a login, and while we don't want persistence, we do want it to be recorded
        $this->sentinel->getUserRepository()->recordLogin($user);

        event( new CmsUserLoggedIn($user, true) );
        return true;
    }