Exemplo n.º 1
0
void ExplorerTreeWidget::ui_editUser()
{
    ExplorerUserTreeItem *userItem = selectedUserItem();
    if (!userItem)
        return;

    MongoUser user = userItem->user();
    MongoDatabase *database = userItem->database();
    MongoServer *server = database->server();

    CreateUserDialog dlg(server->connectionRecord()->getFullAddress(),
                         database->name(),
                         user);
    dlg.setWindowTitle("Edit User");
    dlg.setUserPasswordLabelText("New Password:");
    int result = dlg.exec();

    if (result == QDialog::Accepted) {

        MongoUser user = dlg.user();
        database->createUser(user, true);

        // refresh list of users
        database->loadUsers();
    }
}
Exemplo n.º 2
0
void ExplorerTreeWidget::ui_dropUser()
{
    ExplorerUserTreeItem *userItem = selectedUserItem();
    if (!userItem)
        return;

    MongoUser user = userItem->user();
    MongoDatabase *database = userItem->database();
    MongoServer *server = database->server();

    // Ask user
    int answer = QMessageBox::question(this,
            "Remove User",
            QString("Remove <b>%1</b> user?").arg(user.name()),
            QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);

    if (answer != QMessageBox::Yes)
        return;

    database->dropUser(user.id());
    database->loadUsers(); // refresh list of users
}