Enter password to open seed, keys dialog

This commit is contained in:
tobtoht 2021-06-04 20:48:44 +02:00
parent 2b2107b32d
commit e2a591baed
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
2 changed files with 25 additions and 0 deletions

View file

@ -701,6 +701,10 @@ void MainWindow::showSeedDialog() {
return; return;
} }
if (!this->verifyPassword()) {
return;
}
SeedDialog dialog{m_ctx, this}; SeedDialog dialog{m_ctx, this};
dialog.exec(); dialog.exec();
} }
@ -772,6 +776,10 @@ void MainWindow::showRestoreHeightDialog() {
} }
void MainWindow::showKeysDialog() { void MainWindow::showKeysDialog() {
if (!this->verifyPassword()) {
return;
}
KeysDialog dialog{m_ctx, this}; KeysDialog dialog{m_ctx, this};
dialog.exec(); dialog.exec();
} }
@ -1557,6 +1565,22 @@ void MainWindow::updateRecentlyOpenedMenu() {
ui->menuRecently_open->addAction(m_clearRecentlyOpenAction); ui->menuRecently_open->addAction(m_clearRecentlyOpenAction);
} }
bool MainWindow::verifyPassword() {
bool ok;
while (true) {
QString password = QInputDialog::getText(this, "Enter password", "Please enter your password:", QLineEdit::EchoMode::Password, "", &ok);
if (!ok) { // Dialog cancelled
return false;
}
if (password != m_ctx->wallet->getPassword()) {
QMessageBox::warning(this, "Error", "Incorrect password");
continue;
}
break;
}
return true;
}
void MainWindow::toggleSearchbar(bool visible) { void MainWindow::toggleSearchbar(bool visible) {
config()->set(Config::showSearchbar, visible); config()->set(Config::showSearchbar, visible);

View file

@ -212,6 +212,7 @@ private:
void addToRecentlyOpened(const QString &filename); void addToRecentlyOpened(const QString &filename);
void updateRecentlyOpenedMenu(); void updateRecentlyOpenedMenu();
void updateWidgetIcons(); void updateWidgetIcons();
bool verifyPassword();
QIcon hardwareDevicePairedIcon(); QIcon hardwareDevicePairedIcon();
QIcon hardwareDeviceUnpairedIcon(); QIcon hardwareDeviceUnpairedIcon();