Skip to content

Commit

Permalink
Add custom button "Continue with weak password"
Browse files Browse the repository at this point in the history
  • Loading branch information
egglessness committed Aug 28, 2023
1 parent ed2d517 commit f2d9bee
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
6 changes: 5 additions & 1 deletion share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ Are you sure you want to continue without a password?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>WARNING! Using a weak password may expose your accounts to security risks. Do you wish to continue?</source>
<source>This is a weak password! For better protection of your secrets, you should choose a stronger password.</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down Expand Up @@ -6311,6 +6311,10 @@ Do you want to overwrite it?</source>
<source>Continue</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Continue with weak password</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
Expand Down
1 change: 1 addition & 0 deletions src/gui/MessageBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void MessageBox::initializeButtonDefs()
{Disable, {QMessageBox::tr("Disable"), QMessageBox::ButtonRole::AcceptRole}},
{Merge, {QMessageBox::tr("Merge"), QMessageBox::ButtonRole::AcceptRole}},
{Continue, {QMessageBox::tr("Continue"), QMessageBox::ButtonRole::AcceptRole}},
{ContinueWithWeakPass, {QMessageBox::tr("Continue with weak password"), QMessageBox::ButtonRole::AcceptRole}},
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/gui/MessageBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ class MessageBox
Disable = 1 << 25,
Merge = 1 << 26,
Continue = 1 << 27,
ContinueWithWeakPass = 1 << 28,

// Internal loop markers. Update Last when new KeePassXC button is added
First = Ok,
Last = Continue,
Last = ContinueWithWeakPass,
};

enum Action
Expand Down
13 changes: 6 additions & 7 deletions src/gui/dbsettings/DatabaseSettingsWidgetDatabaseKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,12 @@ bool DatabaseSettingsWidgetDatabaseKey::save()
// Show warning if database password is weak
if (!m_passwordEditWidget->isEmpty()
&& m_passwordEditWidget->getPasswordQuality() < PasswordHealth::Quality::Good) {
auto dialogResult =
MessageBox::warning(this,
tr("Weak password"),
tr("WARNING! Using a weak password may expose your accounts to security risks. "
"Do you wish to continue?"),
MessageBox::Continue | MessageBox::Cancel,
MessageBox::Cancel);
auto dialogResult = MessageBox::warning(this,
tr("Weak password"),
tr("This is a weak password! For better protection of your secrets, "
"you should choose a stronger password."),
MessageBox::ContinueWithWeakPass | MessageBox::Cancel,
MessageBox::Cancel);

if (dialogResult == MessageBox::Cancel) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/gui/TestGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void TestGui::testCreateDatabase()
fileDialog()->setNextFileName(tmpFile.fileName());

// click Continue on the warning due to weak password
MessageBox::setNextAnswer(MessageBox::Continue);
MessageBox::setNextAnswer(MessageBox::ContinueWithWeakPass);
QTest::keyClick(fileEdit, Qt::Key::Key_Enter);

tmpFile.remove(););
Expand Down
2 changes: 1 addition & 1 deletion tests/gui/TestGuiFdoSecrets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,7 @@ bool TestGuiFdoSecrets::driveNewDatabaseWizard()
fileDialog()->setNextFileName(tmpFile.fileName());

// click Continue on the warning due to weak password
MessageBox::setNextAnswer(MessageBox::Continue);
MessageBox::setNextAnswer(MessageBox::ContinueWithWeakPass);
wizard->accept();

tmpFile.remove();
Expand Down

0 comments on commit f2d9bee

Please sign in to comment.