-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass parent to dialogs. Modify button text on Add.
- Loading branch information
1 parent
44b1adc
commit 59de75a
Showing
9 changed files
with
55 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2023 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2024 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2010 Felix Geyer <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -1411,7 +1411,7 @@ void DatabaseWidget::switchToPasskeys() | |
|
||
void DatabaseWidget::showImportPasskeyDialog(bool isEntry) | ||
{ | ||
PasskeyImporter passkeyImporter; | ||
PasskeyImporter passkeyImporter(this); | ||
|
||
if (isEntry) { | ||
auto currentEntry = currentSelectedEntry(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2023 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2024 KeePassXC Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -20,6 +20,8 @@ | |
|
||
#include <QList> | ||
#include <QObject> | ||
#include <QPointer> | ||
#include <QWidget> | ||
|
||
class Entry; | ||
|
||
|
@@ -28,12 +30,15 @@ class PasskeyExporter : public QObject | |
Q_OBJECT | ||
|
||
public: | ||
explicit PasskeyExporter() = default; | ||
explicit PasskeyExporter(QWidget* parent = nullptr); | ||
|
||
void showExportDialog(const QList<Entry*>& items); | ||
|
||
private: | ||
void exportSelectedEntry(const Entry* entry, const QString& folder); | ||
|
||
private: | ||
QPointer<QWidget> m_parent; | ||
}; | ||
|
||
#endif // KEEPASSXC_PASSKEYEXPORTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2023 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2024 KeePassXC Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -30,6 +30,11 @@ | |
|
||
static const QString IMPORTED_PASSKEYS_GROUP = QStringLiteral("Imported Passkeys"); | ||
|
||
PasskeyImporter::PasskeyImporter(QWidget* parent) | ||
: m_parent(parent) | ||
{ | ||
} | ||
|
||
void PasskeyImporter::importPasskey(QSharedPointer<Database>& database, Entry* entry) | ||
{ | ||
auto filter = QString("%1 (*.passkey);;%2 (*)").arg(tr("Passkey file"), tr("All files")); | ||
|
@@ -56,30 +61,26 @@ void PasskeyImporter::importSelectedFile(QFile& file, QSharedPointer<Database>& | |
const auto fileData = file.readAll(); | ||
const auto passkeyObject = browserMessageBuilder()->getJsonObject(fileData); | ||
if (passkeyObject.isEmpty()) { | ||
MessageBox::information(nullptr, | ||
MessageBox::information(m_parent, | ||
tr("Cannot import passkey"), | ||
tr("Cannot import passkey file \"%1\". Data is missing.").arg(file.fileName())); | ||
return; | ||
} | ||
|
||
const auto privateKey = passkeyObject["privateKey"].toString(); | ||
const auto missingKeys = Tools::getMissingValuesFromList<QString>(passkeyObject.keys(), | ||
QStringList() << "relyingParty" | ||
<< "url" | ||
<< "username" | ||
<< "credentialId" | ||
<< "userHandle" | ||
<< "privateKey"); | ||
const auto missingKeys = Tools::getMissingValuesFromList<QString>( | ||
passkeyObject.keys(), | ||
QStringList() << "relyingParty" << "url" << "username" << "credentialId" << "userHandle" << "privateKey"); | ||
|
||
if (!missingKeys.isEmpty()) { | ||
MessageBox::information(nullptr, | ||
MessageBox::information(m_parent, | ||
tr("Cannot import passkey"), | ||
tr("Cannot import passkey file \"%1\".\nThe following data is missing:\n%2") | ||
.arg(file.fileName(), missingKeys.join(", "))); | ||
} else if (!privateKey.startsWith("-----BEGIN PRIVATE KEY-----") | ||
|| !privateKey.trimmed().endsWith("-----END PRIVATE KEY-----")) { | ||
MessageBox::information( | ||
nullptr, | ||
m_parent, | ||
tr("Cannot import passkey"), | ||
tr("Cannot import passkey file \"%1\". Private key is missing or malformed.").arg(file.fileName())); | ||
} else { | ||
|
@@ -101,10 +102,12 @@ bool PasskeyImporter::showImportDialog(QSharedPointer<Database>& database, | |
const QString& userHandle, | ||
const QString& privateKey, | ||
const QString& titleText, | ||
const QString& infoText) | ||
const QString& infoText, | ||
const QString& importButtonText) | ||
{ | ||
PasskeyImportDialog passkeyImportDialog; | ||
passkeyImportDialog.setInfo(relyingParty, username, database, entry != nullptr, titleText, infoText); | ||
PasskeyImportDialog passkeyImportDialog(m_parent); | ||
passkeyImportDialog.setInfo( | ||
relyingParty, username, database, entry != nullptr, titleText, infoText, importButtonText); | ||
|
||
auto ret = passkeyImportDialog.exec(); | ||
if (ret != QDialog::Accepted) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters