From 5c45cf2d764b540c6a1f1c1fcd5d0cc538aa93d1 Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Wed, 30 Mar 2022 00:03:35 +0200 Subject: [PATCH] Clear quick unlock secrets when database tab is closed --- src/gui/DatabaseOpenWidget.cpp | 8 ++++++++ src/gui/DatabaseOpenWidget.h | 2 +- src/gui/DatabaseWidget.cpp | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 92b70470..26ac61d7 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -529,8 +529,16 @@ bool DatabaseOpenWidget::isOnQuickUnlockScreen() return m_ui->centralStack->currentIndex() == 1; } +/** + * Reset installed quick unlock secrets. + * + * It's safe to call this method even if quick unlock is unavailable. + */ void DatabaseOpenWidget::resetQuickUnlock() { + if (!isQuickUnlockAvailable()) { + return; + } #if defined(Q_CC_MSVC) getWindowsHello()->reset(m_filename); #elif defined(Q_OS_MACOS) diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h index df5339bf..8a26b304 100644 --- a/src/gui/DatabaseOpenWidget.h +++ b/src/gui/DatabaseOpenWidget.h @@ -45,6 +45,7 @@ public: void clearForms(); void enterKey(const QString& pw, const QString& keyFile); QSharedPointer database(); + void resetQuickUnlock(); signals: void dialogFinished(bool accepted); @@ -56,7 +57,6 @@ protected: void setUserInteractionLock(bool state); // Quick Unlock helper functions bool isOnQuickUnlockScreen(); - void resetQuickUnlock(); const QScopedPointer m_ui; QSharedPointer m_db; diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index da4b1964..af3245ad 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -1569,6 +1569,7 @@ void DatabaseWidget::closeEvent(QCloseEvent* event) event->ignore(); return; } + m_databaseOpenWidget->resetQuickUnlock(); event->accept(); }