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;
    }