mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-10 03:38:33 -05:00
Show "key already exists" warning only if key really exists
This commit is contained in:
parent
28a67f9957
commit
48ac3790c2
@ -174,15 +174,15 @@ QString BrowserService::storeKey(const QString& key)
|
|||||||
|
|
||||||
Entry* config = getConfigEntry(true);
|
Entry* config = getConfigEntry(true);
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool contains = false;
|
bool contains;
|
||||||
QMessageBox::StandardButton dialogResult = QMessageBox::No;
|
QMessageBox::StandardButton dialogResult = QMessageBox::No;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
id = QInputDialog::getText(0, tr("KeePassXC: New key association request"),
|
id = QInputDialog::getText(nullptr, tr("KeePassXC: New key association request"),
|
||||||
tr("You have received an association "
|
tr("You have received an association "
|
||||||
"request for the above key.\n"
|
"request for the above key.\n"
|
||||||
"If you would like to allow it access "
|
"If you would like to allow it access "
|
||||||
@ -190,13 +190,17 @@ QString BrowserService::storeKey(const QString& key)
|
|||||||
"give it a unique name to identify and accept it."),
|
"give it a unique name to identify and accept it."),
|
||||||
QLineEdit::Normal, QString(), &ok);
|
QLineEdit::Normal, QString(), &ok);
|
||||||
if (!ok || id.isEmpty()) {
|
if (!ok || id.isEmpty()) {
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
contains = config->attributes()->contains(QLatin1String(ASSOCIATE_KEY_PREFIX) + id);
|
contains = config->attributes()->contains(QLatin1String(ASSOCIATE_KEY_PREFIX) + id);
|
||||||
dialogResult = QMessageBox::warning(0, tr("KeePassXC: Overwrite existing key?"),
|
if (contains) {
|
||||||
tr("A shared encryption key with the name \"%1\" already exists.\nDo you want to overwrite it?").arg(id),
|
dialogResult = QMessageBox::warning(nullptr, tr("KeePassXC: Overwrite existing key?"),
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
tr("A shared encryption key with the name \"%1\" "
|
||||||
|
"already exists.\nDo you want to overwrite it?")
|
||||||
|
.arg(id),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
}
|
||||||
} while (contains && dialogResult == QMessageBox::No);
|
} while (contains && dialogResult == QMessageBox::No);
|
||||||
|
|
||||||
config->attributes()->set(QLatin1String(ASSOCIATE_KEY_PREFIX) + id, key, true);
|
config->attributes()->set(QLatin1String(ASSOCIATE_KEY_PREFIX) + id, key, true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user