@see AuthenticationManager::login()

@param $credentials Associative array with the keys 'login' and 'password'
352037
public function login($credentials) {
    if (!isset($credentials['login']) || !isset($credentials['password'])) {
      throw new IllegalArgumentException("The parameters 'login' and 'password' are required");
    }
    $config = ObjectFactory::getInstance('configuration');

    $login = $credentials['login'];
    $password = $credentials['password'];

    // try to receive the user with given credentials
    $user = $this->principalFactory->getUser($login, true);

    // check if user exists
    $loginOk = false;
    if ($user != null && $user->isActive()) {
      // check password
      $loginOk = $user->verifyPassword($password);
      if ($loginOk) {
        // load user config initially
        $userConfig = $user->getConfig();
        if (strlen($userConfig) > 0) {
          $config->addConfiguration($userConfig);
        }
        return $user;
      }
    }
    return null;
  }
1338376
protected function handleLogin(array $credentials = [], $remember = false)
    {
        $loginAttribute = strtolower(config('df.login_attribute', 'email'));
        if ($loginAttribute === 'username') {
            $username = array_get($credentials, 'username');
            if (empty($username)) {
                throw new BadRequestException('Login request is missing required username.');
            }
            unset($credentials['email']);
        } else {
            $email = array_get($credentials, 'email');
            if (empty($email)) {
                throw new BadRequestException('Login request is missing required email.');
            }
            unset($credentials['username']);
        }

        $password = array_get($credentials, 'password');
        if (empty($password)) {
            throw new BadRequestException('Login request is missing required password.');
        }

        $credentials['is_active'] = 1;

        // if user management not available then only system admins can login.
        if (!class_exists('\DreamFactory\Core\User\Resources\System\User')) {
            $credentials['is_sys_admin'] = 1;
        }

        if (Session::authenticate($credentials, $remember, true, $this->getAppId())) {
            return Session::getPublicInfo();
        } else {
            throw new UnauthorizedException('Invalid credentials supplied.');
        }
    }
1100656
protected function validateReset(array $credentials)
    {
        if (is_null($user = $this->getUser($credentials))) {
            return static::INVALID_USER;
        }

        if (! $this->validateNewPassword($credentials)) {
            return static::INVALID_PASSWORD;
        }

        if (! $this->validateToken($user, $credentials)) {
            return static::INVALID_TOKEN;
        }

        if (! $this->validateTimestamp($credentials['expiration'])) {
            return static::EXPIRED_TOKEN;
        }

        return $user;
    }
550783
public function setAuthentication(array $credentials): AbstractClientBuilder
    {
        if (array_key_exists('session_id', $credentials)) {
            $this->authentication = new HeaderAuthenticate($credentials['session_id']);
        } elseif (array_key_exists('username', $credentials) && array_key_exists('password', $credentials)) {
            $this->authentication = new HeaderLogin($credentials['username'], $credentials['password']);
        } else {
            throw new \InvalidArgumentException('No credentials given.');
        }

        return $this;
    }
175890
public function findByCredentials(array $credentials)
	{
		$model     = $this->createModel();
		$loginName = $model->getLoginName();

		if ( ! array_key_exists($loginName, $credentials))
		{
			throw new \InvalidArgumentException("Login attribute [$loginName] was not provided.");
		}

		$passwordName = $model->getPasswordName();

		$query              = $model->newQuery();
		$hashableAttributes = $model->getHashableAttributes();
		$hashedCredentials  = array();

		// build query from given credentials
		foreach ($credentials as $credential => $value)
		{
			// Remove hashed attributes to check later as we need to check these
			// values after we retrieved them because of salts
			if (in_array($credential, $hashableAttributes))
			{
				$hashedCredentials = array_merge($hashedCredentials, array($credential => $value));
			}
			else
			{
				$query = $query->where($credential, '=', $value);
			}
		}

		if ( ! $user = $query->first())
		{
			throw new UserNotFoundException("A user was not found with the given credentials.");
		}

		// Now check the hashed credentials match ours
		foreach ($hashedCredentials as $credential => $value)
		{
			if ( ! $this->hasher->checkhash($value, $user->{$credential}))
			{
				$message = "A user was found to match all plain text credentials however hashed credential [$credential] did not match.";

				if ($credential == $passwordName)
				{
					throw new WrongPasswordException($message);
				}

				throw new UserNotFoundException($message);
			}
			else if ($credential == $passwordName)
			{
				if (method_exists($this->hasher, 'needsRehashed') && 
					$this->hasher->needsRehashed($user->{$credential}))
				{
					// The algorithm used to create the hash is outdated and insecure.
					// Rehash the password and save.
					$user->{$credential} = $value;
					$user->save();
				}
			}
		}

		return $user;
	}
830215
public function login(string $username, string $password): void
    {
        $this->fillUsername($username);
        $this->fillPassword($password);
        $this->clickLogin();
    }
278790
public function retrieveByCredentials(array $credentials)
    {
        // First we will add each credential element to the query as a where clause.
        // Then we can execute the query and, if we found a user, return it in a
        // generic "user" object that will be utilized by the Guard instances.
        $query = $this->conn->table($this->table);

        foreach ($credentials as $key => $value) {
            if (! Str::contains($key, 'password')) {
                $query->where($key, $value);
            }
        }

        // Now we are ready to execute the query to see if we have an user matching
        // the given credentials. If not, we will just return nulls and indicate
        // that there are no matching users for these given credential arrays.
        $user = $query->first();

        if (! is_null($user)) {
            return new GenericUser((array) $user);
        }
    }
1299615
public function authenticate(array $credentials, $remember = false)
    {
        $user = $this->sentry->authenticate($credentials,$remember);
        $this->event->fire('users.login',array($user));
        return $user;
    }
20138
protected function createUser(array $credentials)
    {
        $entity = static::ENTITY_CLASSNAME;

        if (count(array_only($credentials, ['email', 'password', 'username'])) < 3)
        {
            throw new \InvalidArgumentException("Missing arguments.");
        }

        /** @var User $user */
        $user = new $entity(
            $credentials['email'],
            $credentials['password'],
            $credentials['username']
        );

        $rest = array_except($credentials, ['email', 'username', 'password']);
        if (! empty($rest))
        {
            $user->update($rest);
        }

        return $user;
    }
1272339
public function connect(array $credentials): \PDO
    {
        $dsn = 'mysql:';
        $dsnParams = [];
        $pdoOptions = [];
        if (!empty($credentials['host'])) {
            array_push($dsnParams, 'host='.$credentials['host']);
        }
        if (!empty($credentials['port'])) {
            array_push($dsnParams, 'port=' . $credentials['port']);
        }
        if (!empty($credentials['database'])) {
            array_push($dsnParams, 'dbname=' . $credentials['database']);
        }
        if (!empty($credentials['charset'])) {
            array_push($dsnParams, 'charset=' . $credentials['charset']);
        }
        $dsn .= implode(';', $dsnParams);

        if (!empty($credentials['timezone'])) {
            $tzOffset = $this->getMysqlTimeZoneOffset($credentials['timezone']);
            $pdoOptions = [
                \PDO::MYSQL_ATTR_INIT_COMMAND => "SET time_zone = '" . $tzOffset . "'"
            ];
        }

        try {
            $username = $credentials['username'] ?? '';
            $password = $credentials['password'] ?? '';
            $pdo = new \PDO($dsn, $username, $password, $pdoOptions);
            $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
            return $pdo;
        } catch (\PDOException $e) {
            throw new DatabaseException(sprintf('Error connecting to database (%s)', $e->getMessage()));
        }
    }
666010
public function setAuth($login, $password)
    {
        $this->login    = $login;
        $this->password = $password;

        $this->apiClient
            ->setBearerToken(null)
            ->setShopId($this->login)
            ->setShopPassword($this->password);

        return $this;
    }
1156912
public function retrieveByCredentials(array $credentials) {
    	$u = $credentials['username'];
    	$p = $credentials['password'];

    	$m = $this->modelName;

    	// attempt to auth with the credentials provided
    	try
    	{
    		// build the query to retrieve the model instance
    		$user = $m::where($this->username, $u)
    			->first();
    		
    		// if the user is empty then we don't even need to check the
    		// password and we can just return null
    		if(empty($user)) {
    			return null;
    		}

    		// now check the password if we need to do so
    		if(!$this->allow_no_pass) {
    			$pw_attr = $this->password;
    			if(!Hash::check($p, $user->$pw_attr)) {
    				// passwords do not match
    				return null;
    			}
    		}

    		// the authentication was successful
    		return $user;
    	}
    	catch(Exception $e)
    	{
    		// DB access failure, so bubble up the exception
    		// instead of letting it die here; this will assist in debugging
    		throw $e;
    	}
    }
1328434
public function login($login, $api_key)
    {
        if (empty($login) || !is_string($login)) {
            throw new \InvalidArgumentException('Argument "login" cannot be empty and must be a string');
        }

        if (empty($login) || !is_string($api_key)) {
            throw new \InvalidArgumentException('Argument "api_key" cannot be empty and must be a string');
        }

        $this->auth = [
            'login'         => $login,
            'password_hash' => $api_key,
        ];
    }
864708
public function retrieveByCredentials(array $credentials)
	{
		// First we will add each credential element to the query as a where clause.
		// Then we can execute the query and, if we found a user, return it in a
		// generic "user" object that will be utilized by the Guard instances.
		$query = $this->conn->table($this->table);

		foreach ($credentials as $key => $value)
		{
			if ( ! str_contains($key, 'password'))
			{
				$query->where($key, $value);
			}
		}

		// Now we are ready to execute the query to see if we have an user matching
		// the given credentials. If not, we will just return nulls and indicate
		// that there are no matching users for these given credential arrays.
		$user = $query->first();

		return $this->getGenericUser($user);
	}
1072752
public static function authenticate(array $credentials, $remember = false)
    {
        $username = $credentials['username'];
        $password = $credentials['password'];

        $authConfig = getConfigPath('app', 'auth');

        $user = static::user($authConfig, $username);

        /*
         * if authentication requires email activation, we check the database using data provided
         * by the developer data = ['column_name' => 'activation_value'] e.g. [ 'activated' => 1 ]
         */
        if ($user && count($authConfig['activation']) &&
            !static::activated($authConfig['activation'], $user)) {
            return static::NOT_ACTIVATED;
        }

        /*
         * check for password
         */
        if (!verify_secret($password, $user->password)) {
            return static::BAD_CREDENTIALS;
        }

        /**
         * Log in user.
         */
        static::setLoginSession($authConfig, $user);

        /*
         * Remember the user
         */
        if ($remember) {
            static::rememberMe($authConfig, $user);
        }

        return static::VALID;
    }
540169
public function setCredentials($username, $password)
    {
        $this->setCurlOption(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        $this->setCurlOption(CURLOPT_USERPWD, $username . ":" . $password);
    }
1161534
protected function setCredentials($memcached, $credentials)
    {
        list($username, $password) = $credentials;

        $memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true);

        $memcached->setSaslAuthData($username, $password);
    }