From f78d0ba1cb7ddb70fdd33d9ce1413cc516cabe22 Mon Sep 17 00:00:00 2001 From: Erik Moeller Date: Mon, 9 Mar 2020 18:20:51 -0700 Subject: [PATCH 1/2] Update login error messages per UI messages audit --- securedrop_client/gui/widgets.py | 15 +++++++++------ securedrop_client/logic.py | 3 ++- tests/test_logic.py | 5 +++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/securedrop_client/gui/widgets.py b/securedrop_client/gui/widgets.py index 80f9d6110..e042527d6 100644 --- a/securedrop_client/gui/widgets.py +++ b/securedrop_client/gui/widgets.py @@ -1346,7 +1346,7 @@ def __init__(self): self.error_icon.setFixedWidth(42) # Error status bar - self.error_status_bar = QLabel() + self.error_status_bar = SecureQLabel(wordwrap=False) self.error_status_bar.setObjectName('error_status_bar') self.setFixedHeight(42) @@ -1557,7 +1557,7 @@ def error(self, message): """ self.setDisabled(False) self.submit.setText(_("SIGN IN")) - self.error_bar.set_message(html.escape(message)) + self.error_bar.set_message(message) def validate(self): """ @@ -1575,13 +1575,15 @@ def validate(self): # Validate username if len(username) < self.MIN_JOURNALIST_USERNAME: self.setDisabled(False) - self.error(_('Your username should be at least 3 characters. ')) + self.error(_('That username won\'t work.\n' + 'It should be at least 3 characters long.')) return # Validate password if len(password) < self.MIN_PASSWORD_LEN or len(password) > self.MAX_PASSWORD_LEN: self.setDisabled(False) - self.error(_('Your password should be between 14 and 128 characters. ')) + self.error(_('That passphrase won\'t work.\n' + 'It should be between 14 and 128 characters long.')) return # Validate 2FA token @@ -1589,13 +1591,14 @@ def validate(self): int(tfa_token) except ValueError: self.setDisabled(False) - self.error(_('Please use only numerals for the two-factor code.')) + self.error(_('That two-factor code won\'t work.\n' + 'It should only contain numerals.')) return self.submit.setText(_("SIGNING IN")) self.controller.login(username, password, tfa_token) else: self.setDisabled(False) - self.error(_('Please enter a username, password and ' + self.error(_('Please enter a username, passphrase and ' 'two-factor code.')) diff --git a/securedrop_client/logic.py b/securedrop_client/logic.py index 5a69845ca..a5cd310f6 100644 --- a/securedrop_client/logic.py +++ b/securedrop_client/logic.py @@ -396,7 +396,8 @@ def on_authenticate_success(self, result): def on_authenticate_failure(self, result: Exception) -> None: # Failed to authenticate. Reset state with failure message. self.invalidate_token() - error = _('There was a problem signing in. Please verify your credentials and try again.') + error = _('That didn\'t work. Please check everything and try again.\n' + 'Make sure to use a new two-factor code.') self.gui.show_login_error(error=error) self.api_sync.stop() diff --git a/tests/test_logic.py b/tests/test_logic.py index e9dcb0a24..c65ca8658 100644 --- a/tests/test_logic.py +++ b/tests/test_logic.py @@ -189,8 +189,9 @@ def test_Controller_on_authenticate_failure(homedir, config, mocker, session_mak co.api_sync.stop.assert_called_once_with() mock_gui.show_login_error.\ - assert_called_once_with(error='There was a problem signing in. Please ' - 'verify your credentials and try again.') + assert_called_once_with(error='That didn\'t work. ' + 'Please check everything and try again.\n' + 'Make sure to use a new two-factor code.') def test_Controller_on_authenticate_success(homedir, config, mocker, session_maker, From 444cb84f6dfae483f888ed8d9ed13ca79d0510f1 Mon Sep 17 00:00:00 2001 From: Erik Moeller Date: Mon, 9 Mar 2020 23:04:02 -0700 Subject: [PATCH 2/2] Fix application name in version string --- securedrop_client/gui/widgets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/securedrop_client/gui/widgets.py b/securedrop_client/gui/widgets.py index e042527d6..c8cfc685c 100644 --- a/securedrop_client/gui/widgets.py +++ b/securedrop_client/gui/widgets.py @@ -1504,7 +1504,7 @@ def __init__(self, parent): application_version = QWidget() application_version_layout = QHBoxLayout() application_version.setLayout(application_version_layout) - application_version_label = QLabel(_("Workstation app v") + sd_version) + application_version_label = QLabel(_("SecureDrop Client v") + sd_version) application_version_label.setAlignment(Qt.AlignHCenter) application_version_label.setStyleSheet("QLabel {color: #9fddff;}") application_version_layout.addWidget(application_version_label)