Skip to content

Commit bc91227

Browse files
committed
- Add logout page and route that directs users to click the New Identity button in Tor browser to complete their session, if they were logged in, else redirectst to main source interface page.
- Remove logout_flashed message since we redirect to a new page now. - Update functional tests to include _is_on_logout_page method and replace test_logout_flashed_message with test_logout screenshot in testsourcelayout
1 parent a0e2674 commit bc91227

File tree

8 files changed

+29
-18
lines changed

8 files changed

+29
-18
lines changed

securedrop/source_app/main.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,21 @@ def login():
296296

297297
@view.route('/logout')
298298
def logout():
299+
"""
300+
If a user is logged in, show them a logout page that prompts them to
301+
click the New Identity button in Tor Browser to complete their session.
302+
Otherwise redirect to the main Source Interface page.
303+
"""
299304
if logged_in():
300-
msg = render_template('logout_flashed_message.html')
301305

302306
# Clear the session after we render the message so it's localized
303307
# If a user specified a locale, save it and restore it
304308
user_locale = g.locale
305309
session.clear()
306310
session['locale'] = user_locale
307311

308-
flash(Markup(msg), "important hide-if-not-tor-browser")
309-
return redirect(url_for('.index'))
312+
return render_template('logout.html')
313+
else:
314+
return redirect(url_for('.index'))
310315

311316
return view
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% extends "base.html" %}
2+
{% block body %}
3+
<h1>{{ gettext('One more thing...') }}</h1>
4+
<br>
5+
<p id="click-new-identity-tor"> {{ gettext('Click the <img src={icon} alt="broom icon" width="16" height="16">&nbsp;<strong>New Identity</strong> button in your Tor browser\'s toolbar. This will clear your Tor browser activity data on this device.').format(icon=url_for('static', filename='i/torbroom-black.png')) }}</p>
6+
{% endblock %}

securedrop/source_templates/logout_flashed_message.html

Lines changed: 0 additions & 6 deletions
This file was deleted.

securedrop/source_templates/session_timeout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<img src="{{ url_for('static', filename='i/hand_with_fingerprint.png') }}">
44
</div>
55
<div class="message"><strong>{{ gettext('Important!') }}</strong><br>
6-
<p>{{ gettext('Your session timed out due to inactivity. Please login again if you want to continue using SecureDrop, or select "New Identity" from the onion button in the Tor browser\'s toolbar to clear all history of your SecureDrop usage from this device. If you are not using Tor Browser, restart your browser.') }}</p>
6+
<p>{{ gettext('You were logged out due to inactivity. Click the <img src={icon} alt="broom icon" width="16" height="16">&nbsp;<strong>New Identity</strong> button in your Tor browser\'s toolbar. This will clear your Tor browser activity data on this device.').format(icon=url_for('static', filename='i/torbroom-black.png')) }}</p>
77
</div>
88
</div>
1.85 KB
Loading

securedrop/tests/functional/source_navigation_steps.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ def _is_on_lookup_page(self):
1919
def _is_on_generate_page(self):
2020
return self.wait_for(lambda: self.driver.find_element_by_id("create-form"))
2121

22+
def _is_on_logout_page(self):
23+
return self.wait_for(lambda: self.driver.find_element_by_id("click-new-identity-tor"))
24+
2225
def _source_visits_source_homepage(self):
2326
self.driver.get(self.source_location)
2427
assert self._is_on_source_homepage()
@@ -195,7 +198,7 @@ def reply_deleted():
195198

196199
def _source_logs_out(self):
197200
self.safe_click_by_id("logout")
198-
self.wait_for(lambda: ("Submit for the first time" in self.driver.page_source))
201+
assert self._is_on_logout_page()
199202

200203
def _source_not_found(self):
201204
self.driver.get(self.source_location + "/unlikely")
@@ -218,7 +221,7 @@ def _source_sees_session_timeout_message(self):
218221
notification = self.driver.find_element_by_css_selector(".important")
219222

220223
if not hasattr(self, "accept_languages"):
221-
expected_text = "Your session timed out due to inactivity."
224+
expected_text = "You were logged out due to inactivity."
222225
assert expected_text in notification.text
223226

224227
def _source_sees_document_attachment_item(self):

securedrop/tests/pageslayout/test_source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ def test_index(self):
153153
self._source_visits_source_homepage()
154154
self._screenshot('source-index.png')
155155

156-
def test_logout_flashed_message(self):
156+
def test_logout(self):
157157
self.disable_js_torbrowser_driver()
158158
self._source_visits_source_homepage()
159159
self._source_chooses_to_submit_documents()
160160
self._source_continues_to_submit_page()
161161
self._source_submits_a_file()
162162
self._source_logs_out()
163-
self._screenshot('source-logout_flashed_message.png')
163+
self._screenshot('source-logout_page.png')

securedrop/tests/test_source.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ def test_login_and_logout(source_app):
251251
assert 'logged_in' not in session
252252
assert 'codename' not in session
253253
text = resp.data.decode('utf-8')
254-
assert 'Thank you for exiting your session!' in text
254+
255+
# This is part of the logout page message instructing users
256+
# to click the 'New Identity' icon
257+
assert 'This will clear your Tor browser activity data' in text
255258

256259

257260
def test_user_must_log_in_for_protected_views(source_app):
@@ -706,7 +709,7 @@ def test_source_session_expiration(config, source_app):
706709
assert not session
707710

708711
text = resp.data.decode('utf-8')
709-
assert 'Your session timed out due to inactivity' in text
712+
assert 'You were logged out due to inactivity' in text
710713

711714

712715
def test_source_session_expiration_create(config, source_app):
@@ -731,7 +734,7 @@ def test_source_session_expiration_create(config, source_app):
731734
assert not session
732735

733736
text = resp.data.decode('utf-8')
734-
assert 'Your session timed out due to inactivity' in text
737+
assert 'You were logged out due to inactivity' in text
735738

736739

737740
def test_csrf_error_page(config, source_app):
@@ -743,7 +746,7 @@ def test_csrf_error_page(config, source_app):
743746

744747
resp = app.post(url_for('main.create'), follow_redirects=True)
745748
text = resp.data.decode('utf-8')
746-
assert 'Your session timed out due to inactivity' in text
749+
assert 'You were logged out due to inactivity' in text
747750

748751

749752
def test_source_can_only_delete_own_replies(source_app):

0 commit comments

Comments
 (0)