Skip to content

Commit

Permalink
Merge pull request #903 from freedomofpress/string-updates
Browse files Browse the repository at this point in the history
Update login UI messages per UI messages audit
  • Loading branch information
redshiftzero authored Mar 13, 2020
2 parents 28a5ce3 + 444cb84 commit ade88d4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
17 changes: 10 additions & 7 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
"""
Expand All @@ -1575,27 +1575,30 @@ 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
try:
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.'))


Expand Down
3 changes: 2 additions & 1 deletion securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
5 changes: 3 additions & 2 deletions tests/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ade88d4

Please sign in to comment.