Problem with query "q" parameter



  • Hello all!

    I have next function:
    @
    void CEnginioStorage::requestTop(const QString& language, const QString& toLanguage, int top)
    {
    QJsonObject topQuery;
    topQuery["objectType"] = QString("objects.Word");
    QJsonObject parameters;
    parameters["language"] = language;
    parameters["to"] = toLanguage;
    topQuery["q"] = parameters;
    QJsonObject sortParameter;
    sortParameter["sortBy"] = QString("rate");
    sortParameter["direction"] = QString("desc");
    QJsonArray sortArray;
    sortArray.append(sortParameter);
    topQuery["sort"] = sortArray;
    topQuery["limit"] = top;
    EnginioReply* pReply = m_enginioClient.query(topQuery);
    connect(pReply, &EnginioReply::finished, [](EnginioReply* pReply)
    {
    QJsonArray results = pReply->data()["results"].toArray();
    for (QJsonValue word : results)
    qDebug() << word.toObject()["rate"];
    });
    }
    @

    The problem that Enginio ignore my "q" property, but other parameters, "sort" and "limit", work fine.



  • try "query" instead of "q", that is one of things that we still need to review, in future probably we will accept both.



  • Yes, this is work!
    Thank you!



  • Problem with this code again.

    I have next code:
    @void CEnginioStorage::requestTop(const QString& language, const QString& toLanguage, int top)
    {
    QJsonObject topQuery;
    topQuery["objectType"] = QString("objects.Word");
    QJsonObject parameters;
    parameters["language"] = language;
    parameters["to"] = toLanguage;
    topQuery["query"] = parameters;
    QJsonObject sortParameter;
    sortParameter["sortBy"] = QString("rate");
    sortParameter["direction"] = QString("desc");
    QJsonArray sortArray;
    sortArray.append(sortParameter);
    topQuery["sort"] = sortArray;
    topQuery["limit"] = top;
    EnginioReply* pReply = m_enginioClient.query(topQuery);
    connect(pReply, &EnginioReply::finished, [](EnginioReply* pReply)
    {
    if (!pReply->isError()) {
    QJsonArray results = pReply->data()["results"].toArray();
    for (QJsonValue word : results)
    qDebug() << word.toObject()["rate"];
    } else {
    qDebug() << pReply->data();
    }
    });
    }@

    And I have next result:

    @QJsonObject({"errors": [{"message": "Access denied","reason": "Forbidden"}]}) @

    I updated code from git. Before this code was work.
    I gave read privilege only for creators.



  • Are you authenticated? Check m_enginioClient.authenticationState() what does it return?



  • Yes, I'm authenticated.

    I found temproary solution - I gave read permissons for all and add user creator field in query:

    @void CEnginioStorage::requestTop(const QString& language, const QString& toLanguage, int top)
    {
    QJsonObject topQuery;
    topQuery["objectType"] = QString("objects.Word");
    QJsonObject parameters;
    parameters["language"] = language;
    parameters["to"] = toLanguage;
    QJsonObject user;
    user["$type"] = QString("ref");
    user["id"] = m_currentUserId;
    user["objectType"] = QString("users");
    parameters["creator"] = user;
    topQuery["query"] = parameters;
    QJsonObject sortParameter;
    sortParameter["sortBy"] = QString("rate");
    sortParameter["direction"] = QString("desc");
    QJsonArray sortArray;
    sortArray.append(sortParameter);
    topQuery["sort"] = sortArray;
    topQuery["limit"] = top;
    EnginioReply* pReply = m_enginioClient.query(topQuery);
    connect(pReply, &EnginioReply::finished, [](EnginioReply* pReply)
    {
    if (!pReply->isError()) {
    QJsonArray results = pReply->data()["results"].toArray();
    for (QJsonValue word : results)
    qDebug() << word.toObject()["rate"];
    } else {
    qDebug() << pReply->data();
    }
    });
    }@

    But this is not very good for me. I need to get access for all objects that I created by default.



  • It is definitely related to authentication. We moved to OAuth2 so it could be a regression. Could you tell me:

    • when exactly you pulled (sha1)?
    • do you use "basic" authentication or "oauth2" ?
    • what is the EnginioClient::authenticationStatus in the function?
    • have you tried to debug authentication problem by connecting to EnginioClient::sessionAuthenticated, EnginioClient::sessionAuthenticationError and EnginioClient::sessionTerminated signals?


  • I just replaced to EnginioOAuth2Authentication old object for Authorization.



  • Ok, please register a bug report (https://bugreports.qt-project.org) with a minimal example reproducing the problem.



  • Could you double check that permission settings on your backend configuration are in such way as you want the access control behave?

    Enginio's access control model has two different read permissions controlling who is able to read and query individual objects.

    • Collection Read permission controls on object type level who is able to query objects of that type
    • Object Read controls on individual object level who can get that objects data

    Together those two read permissions form following combinations:
    !https://dl.dropboxusercontent.com/u/99671592/EnginioPublishedMaterial/Enginio_CollectionAndObjectReadPermissions.png(Enginio - Collection and Object Read permission combinations)!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.