How to set admin permissions for user



  • I have special user - StudentsCreator. He can create users and after create StudentsCreator is admin for created users.
    I want to redefine admin permissons to user that created. From StudentsCreator I did next code:
    @
    QJsonObject query;
    query["id"] = userId;
    query["objectType"] = QString("users");
    QJsonArray admins;
    QJsonObject user;
    user["id"] = userId;
    user["objectType"] = QString("users");
    admins.push_back(user);
    query["admin"] = admins;
    EnginioReply* pAddMemberOperation = m_pEnginioClient->update(query, Enginio::AccessControlOperation);@

    But I recieved next error:
    @{"message":"Internal server error"}@



  • I resolve my problem. See code below:
    @void CEnginioUserCreator::addUserPermisions(EnginioReply pReply)
    {
    if (pReply->isError())
    emit userAddResult(m_login, m_password, tr("Login already exist"));
    else {
    m_createdUserId = pReply->data()["id"].toString();
    QJsonObject user;
    user["id"] = m_createdUserId;
    user["objectType"] = QString("users");
    QJsonArray admins;
    admins.push_back(user);
    QJsonObject access;
    access["admin"] = admins;
    user["access"] = access;
    EnginioReply
    pAddMemberOperation = m_pEnginioClient->update(user, Enginio::AccessControlOperation);
    connect(pAddMemberOperation, &EnginioReply::finished,
    [&](EnginioReply * pReply)
    {
    if (pReply->isError()) {
    QJsonObject user;
    user["id"] = m_createdUserId;
    user["objectType"] = QString("users");
    m_pEnginioClient->remove(user);
    emit userAddResult(m_login, m_password, pReply->errorString());
    }
    else {
    QJsonObject query;
    query["id"] = m_createdUserId;
    query["objectType"] = QString("users");
    QJsonObject studentsCreator;
    studentsCreator["id"] = g_studentCreatorId;
    studentsCreator["objectType"] = QString("users");
    QJsonArray admins;
    admins.push_back(studentsCreator);
    QJsonObject access;
    access["admin"] = admins;
    query["access"] = access;
    m_pEnginioClient->remove(query, Enginio::AccessControlOperation);
    emit userAddResult(m_login, m_password, QString());
    }
    });
    }
    }@


Log in to reply
 

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