End user can now specify how long password manager remembers the master key.
Closes $24
This commit is contained in:
parent
d489f11e52
commit
7f88b98cdd
2 changed files with 31 additions and 3 deletions
|
|
@ -10,12 +10,21 @@
|
|||
#include "ConnectionConfigurationWidget.h"
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
ConnectionController::ConnectionController(MasterController *parent)
|
||||
: QObject(parent)
|
||||
, m_masterController(parent)
|
||||
{}
|
||||
, m_relockTimer(new QTimer(this))
|
||||
{
|
||||
m_relockTimer->setSingleShot(true);
|
||||
m_relockTimer->setTimerType(Qt::VeryCoarseTimer);
|
||||
// Force signal to go through queue so when the password manager is relocked after 0msec
|
||||
// the code that retrieves the password is garanteed to run before the signal is handled
|
||||
// because only after the password is retrieved the loop has a chance to run.
|
||||
m_relockTimer->callOnTimeout(this, &ConnectionController::relock, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
ConnectionController::~ConnectionController()
|
||||
{
|
||||
|
|
@ -194,7 +203,7 @@ bool ConnectionController::UnlockPasswordManagerIfNeeded()
|
|||
|
||||
while (true) {
|
||||
// ask user for passphrase
|
||||
auto dlg = std::make_unique<PasswordPromptDialog>(nullptr, nullptr);
|
||||
auto dlg = std::make_unique<PasswordPromptDialog>(PasswordPromptDialog::RememberPassword, nullptr);
|
||||
dlg->setCaption(tr("Unlock password manager"));
|
||||
dlg->setDescription(tr("Enter password for password manager"));
|
||||
int exec_result = dlg->exec();
|
||||
|
|
@ -205,8 +214,14 @@ bool ConnectionController::UnlockPasswordManagerIfNeeded()
|
|||
break;
|
||||
}
|
||||
// user gave OK, if succeeds return true otherwise loop a prompt for password again.
|
||||
if (m_passwordManager->openDatabase(user_cfg_db, dlg->password()))
|
||||
if (m_passwordManager->openDatabase(user_cfg_db, dlg->password())) {
|
||||
int rem = dlg->remember();
|
||||
if (rem >= 0) {
|
||||
int timeout = rem * 60 * 1000; /// rem is in minutes, timeout in millisec
|
||||
m_relockTimer->start(timeout);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -234,5 +249,10 @@ std::string ConnectionController::getPskId(const ConnectionConfig &cc)
|
|||
return id;
|
||||
}
|
||||
|
||||
void ConnectionController::relock()
|
||||
{
|
||||
m_passwordManager->closeDatabase();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue