-
-
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.
Launch KeePassXC password generator popup from the extension
- Loading branch information
varjolintu
committed
May 16, 2021
1 parent
60adcac
commit b2b4a0b
Showing
8 changed files
with
55 additions
and
343 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2020 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2021 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 | ||
|
@@ -21,6 +21,7 @@ | |
#include "BrowserShared.h" | ||
#include "config-keepassx.h" | ||
#include "core/Global.h" | ||
#include "gui/PasswordGeneratorWidget.h" | ||
|
||
#include <QJsonDocument> | ||
#include <QJsonParseError> | ||
|
@@ -303,25 +304,19 @@ QJsonObject BrowserAction::handleGetLogins(const QJsonObject& json, const QStrin | |
|
||
QJsonObject BrowserAction::handleGeneratePassword(const QJsonObject& json, const QString& action) | ||
{ | ||
auto errorMessage = getErrorReply(action, ERROR_KEEPASS_ACTION_CANCELLED_OR_DENIED); | ||
auto nonce = json.value("nonce").toString(); | ||
auto password = browserSettings()->generatePassword(); | ||
auto generator = browserService()->showPasswordGenerator(errorMessage); | ||
|
||
if (nonce.isEmpty() || password.isEmpty()) { | ||
return QJsonObject(); | ||
} | ||
|
||
// For backwards compatibility | ||
password["login"] = password["entropy"]; | ||
|
||
QJsonArray arr; | ||
arr.append(password); | ||
|
||
const QString newNonce = incrementNonce(nonce); | ||
connect(generator, &PasswordGeneratorWidget::appliedPassword, [=](QString password) { | ||
const QString newNonce = incrementNonce(nonce); | ||
QJsonObject message = buildMessage(newNonce); | ||
message["password"] = password; | ||
|
||
QJsonObject message = buildMessage(newNonce); | ||
message["entries"] = arr; | ||
browserService()->sendPassword(buildResponse(action, message, newNonce)); | ||
}); | ||
|
||
return buildResponse(action, message, newNonce); | ||
return QJsonObject(); | ||
} | ||
|
||
QJsonObject BrowserAction::handleSetLogin(const QJsonObject& json, const QString& action) | ||
|
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) 2020 KeePassXC Team <[email protected]> | ||
* Copyright (C) 2021 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 | ||
|
@@ -19,10 +19,13 @@ | |
#define BROWSERACTION_H | ||
|
||
#include <QJsonObject> | ||
#include <QObject> | ||
#include <QString> | ||
|
||
class BrowserAction | ||
class BrowserAction : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit BrowserAction() = default; | ||
~BrowserAction() = default; | ||
|
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
Oops, something went wrong.