mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
EncryptedPasswordBackend: Make sure only one ask password dialog is visible at time.
This commit is contained in:
parent
7a0a4ea31e
commit
f6449b0402
@ -34,6 +34,8 @@
|
||||
DatabaseEncryptedPasswordBackend::DatabaseEncryptedPasswordBackend()
|
||||
: PasswordBackend()
|
||||
, m_stateOfMasterPassword(UnKnownState)
|
||||
, m_askPasswordDialogVisible(false)
|
||||
, m_askMasterPassword(false)
|
||||
{
|
||||
QSqlDatabase db = QSqlDatabase::database();
|
||||
if (!db.tables().contains(QLatin1String("autofill_encrypted"))) {
|
||||
@ -263,24 +265,37 @@ bool DatabaseEncryptedPasswordBackend::hasPermission()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
QString text = QInputDialog::getText(mApp->getWindow(), AutoFill::tr("Enter Master Password"),
|
||||
AutoFill::tr("Permission is required, please enter Master Password:"),
|
||||
QLineEdit::Password, QString(), &ok);
|
||||
if (ok && !text.isEmpty()) {
|
||||
QByteArray enteredPassword = AesInterface::passwordToHash(text);
|
||||
if (m_askPasswordDialogVisible) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_askPasswordDialogVisible = true;
|
||||
|
||||
QInputDialog dialog;
|
||||
dialog.setWindowModality(Qt::ApplicationModal);
|
||||
dialog.setWindowTitle(AutoFill::tr("Enter Master Password"));
|
||||
dialog.setLabelText(AutoFill::tr("Permission is required, please enter Master Password:"));
|
||||
dialog.setTextEchoMode(QLineEdit::Password);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted && !dialog.textValue().isEmpty()) {
|
||||
QByteArray enteredPassword = AesInterface::passwordToHash(dialog.textValue());
|
||||
if (!isPasswordVerified(enteredPassword)) {
|
||||
QMessageBox::information(mApp->getWindow(), AutoFill::tr("Warning!"), AutoFill::tr("Entered password is wrong!"));
|
||||
setAskMasterPasswordState(true);
|
||||
|
||||
m_askPasswordDialogVisible = false;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
setAskMasterPasswordState(false);
|
||||
//TODO: start timer for reset ask state to true
|
||||
|
||||
m_askPasswordDialogVisible = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
m_askPasswordDialogVisible = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QInputDialog;
|
||||
|
||||
class AesInterface;
|
||||
class MasterPasswordDialog;
|
||||
|
||||
@ -85,6 +87,7 @@ private:
|
||||
MasterPasswordState m_stateOfMasterPassword;
|
||||
QByteArray m_someDataStoredOnDataBase;
|
||||
|
||||
bool m_askPasswordDialogVisible;
|
||||
bool m_askMasterPassword;
|
||||
QByteArray m_masterPassword;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user