Skip to content

Commit

Permalink
Add password strength indicator to PasswordEditWidget
Browse files Browse the repository at this point in the history
Fixes #7437 (entry edit view only)
Fixes #5220
  • Loading branch information
jmdana committed Apr 14, 2022
1 parent 692c95b commit 5e30494
Show file tree
Hide file tree
Showing 24 changed files with 2,973 additions and 2,664 deletions.
106 changes: 70 additions & 36 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1426,10 +1426,6 @@ Backup database located at %2</source>
<source>Key File:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;In addition to a password, you can use a secret file to enhance the security of your database. This file can be generated in your database&apos;s security settings.&lt;/p&gt;&lt;p&gt;This is &lt;strong&gt;not&lt;/strong&gt; your *.kdbx database file!&lt;br&gt;If you do not have a key file, leave this field empty.&lt;/p&gt;&lt;p&gt;Click for more information…&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Key file help</source>
<translation type="unfinished"></translation>
Expand All @@ -1442,11 +1438,6 @@ Backup database located at %2</source>
<source>Hardware Key:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;You can use a hardware security key such as a &lt;strong&gt;YubiKey&lt;/strong&gt; or &lt;strong&gt;OnlyKey&lt;/strong&gt; with slots configured for HMAC-SHA1.&lt;/p&gt;
&lt;p&gt;Click for more information…&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hardware key help</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -1581,6 +1572,23 @@ If you do not have a key file, please leave the field empty.</source>
<source>Select hardware key…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;In addition to a password, you can use a secret file to
enhance the security of your database. This file can be generated in your
database&apos;s security settings.&lt;/p&gt;&lt;p&gt;This is &lt;strong&gt;not&lt;/strong&gt;
your *.kdbx database file!&lt;br&gt;If you do not have a key file, leave
this field empty.&lt;/p&gt;&lt;p&gt;Click for more information…&lt;/p&gt;
</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;You can use a hardware security key such as a &lt;strong&gt;YubiKey&lt;/strong&gt;
or &lt;strong&gt;OnlyKey&lt;/strong&gt; with slots configured for
HMAC-SHA1.&lt;/p&gt;
&lt;p&gt;Click for more information…&lt;/p&gt;
</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DatabaseSettingWidgetMetaData</name>
Expand Down Expand Up @@ -5749,29 +5757,6 @@ We recommend you use the AppImage available on our downloads page.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PasswordEdit</name>
<message>
<source>Passwords do not match</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Passwords match so far</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle Password (%1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Generate Password (%1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Warning: Caps Lock enabled!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PasswordEditWidget</name>
<message>
Expand Down Expand Up @@ -5950,10 +5935,6 @@ We recommend you use the AppImage available on our downloads page.</source>
<source>Also choose from:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Excluded characters: &quot;0&quot;, &quot;1&quot;, &quot;l&quot;, &quot;I&quot;, &quot;O&quot;, &quot;|&quot;, &quot;&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exclude look-alike characters</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -6103,6 +6084,59 @@ Do you want to overwrite it?</source>
<comment>Password quality</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Excluded characters: &quot;0&quot;, &quot;1&quot;, &quot;l&quot;, &quot;I&quot;,
&quot;O&quot;, &quot;|&quot;, &quot;&quot;
</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PasswordWidget</name>
<message>
<source>Passwords do not match</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Passwords match so far</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle Password (%1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Generate Password (%1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Warning: Caps Lock enabled!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Quality: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Poor</source>
<comment>Password quality</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Weak</source>
<comment>Password quality</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Good</source>
<comment>Password quality</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Excellent</source>
<comment>Password quality</comment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PickcharsDialog</name>
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ set(keepassx_SOURCES
gui/MessageBox.cpp
gui/MessageWidget.cpp
gui/OpVaultOpenWidget.cpp
gui/PasswordEdit.cpp
gui/PasswordWidget.cpp
gui/PasswordGeneratorWidget.cpp
gui/ApplicationSettingsWidget.cpp
gui/Icons.cpp
Expand Down
6 changes: 3 additions & 3 deletions src/autotype/PickcharsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ PickcharsDialog::PickcharsDialog(const QString& string, QWidget* parent)
// Remove last selected character
auto shortcut = new QShortcut(Qt::Key_Backspace, this);
connect(shortcut, &QShortcut::activated, this, [this] {
auto text = m_ui->selectedChars->text();
auto text = m_ui->selectedChars->getText();
m_ui->selectedChars->setText(text.left(text.size() - 1));
});
// Submit the form
Expand Down Expand Up @@ -134,7 +134,7 @@ void PickcharsDialog::downPressed()

QString PickcharsDialog::selectedChars()
{
return m_ui->selectedChars->text();
return m_ui->selectedChars->getText();
}

bool PickcharsDialog::pressTab()
Expand All @@ -149,7 +149,7 @@ void PickcharsDialog::charSelected()
return;
}

m_ui->selectedChars->setText(m_ui->selectedChars->text() + btn->property("char").toChar());
m_ui->selectedChars->setText(m_ui->selectedChars->getText() + btn->property("char").toChar());
}

void PickcharsDialog::showEvent(QShowEvent* event)
Expand Down
8 changes: 4 additions & 4 deletions src/autotype/PickcharsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<layout class="QGridLayout" name="charsGrid"/>
</item>
<item>
<widget class="PasswordEdit" name="selectedChars">
<widget class="PasswordWidget" name="selectedChars">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -74,9 +74,9 @@
</widget>
<customwidgets>
<customwidget>
<class>PasswordEdit</class>
<extends>QLineEdit</extends>
<header>gui/PasswordEdit.h</header>
<class>PasswordWidget</class>
<extends>QWidget</extends>
<header>gui/PasswordWidget.h</header>
</customwidget>
</customwidgets>
<tabstops>
Expand Down
8 changes: 4 additions & 4 deletions src/gui/DatabaseOpenWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void DatabaseOpenWidget::openDatabase()
emit dialogFinished(true);
clearForms();
} else {
if (!isOnQuickUnlockScreen() && m_ui->editPassword->text().isEmpty() && !m_retryUnlockWithEmptyPassword) {
if (!isOnQuickUnlockScreen() && m_ui->editPassword->getText().isEmpty() && !m_retryUnlockWithEmptyPassword) {
QScopedPointer<QMessageBox> msgBox(new QMessageBox(this));
msgBox->setIcon(QMessageBox::Critical);
msgBox->setWindowTitle(tr("Unlock failed and no password given"));
Expand Down Expand Up @@ -348,15 +348,15 @@ QSharedPointer<CompositeKey> DatabaseOpenWidget::buildDatabaseKey()
return databaseKey;
}

if (!m_ui->editPassword->text().isEmpty() || m_retryUnlockWithEmptyPassword) {
databaseKey->addKey(QSharedPointer<PasswordKey>::create(m_ui->editPassword->text()));
if (!m_ui->editPassword->getText().isEmpty() || m_retryUnlockWithEmptyPassword) {
databaseKey->addKey(QSharedPointer<PasswordKey>::create(m_ui->editPassword->getText()));
}

auto lastKeyFiles = config()->get(Config::LastKeyFiles).toHash();
lastKeyFiles.remove(m_filename);

auto key = QSharedPointer<FileKey>::create();
QString keyFilename = m_ui->keyFileLineEdit->text();
QString keyFilename = m_ui->keyFileLineEdit->getText();
if (!keyFilename.isEmpty()) {
QString errorMsg;
if (!key->load(keyFilename, &errorMsg)) {
Expand Down
Loading

0 comments on commit 5e30494

Please sign in to comment.