Skip to content

Commit

Permalink
Add logout page and route that directs users to click the New Identit…
Browse files Browse the repository at this point in the history
…y button in Tor browser to complete their session, if they were logged in, else redirectst to main source interface page.

Update functional tests (wip) and add id to logout element
  • Loading branch information
rocodes committed Feb 5, 2020
1 parent d151a30 commit 7d24c43
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
11 changes: 8 additions & 3 deletions securedrop/source_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,21 @@ def login():

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

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

flash(Markup(msg), "important hide-if-not-tor-browser")
return redirect(url_for('.index'))
return render_template('logout.html')
else:
return redirect(url_for('.index'))

return view
5 changes: 5 additions & 0 deletions securedrop/source_templates/logout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "base.html" %}
{% block body %}
<h1>{{ gettext('One last thing') }}</h1>
<p id="click-new-identity-tor">{{ gettext('Click the <strong>New Identity</strong> button in your Tor browser window to complete your session.') }}</p>
{% endblock %}
3 changes: 2 additions & 1 deletion securedrop/tests/functional/source_navigation_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ def reply_deleted():

def _source_logs_out(self):
self.safe_click_by_id("logout")
self.wait_for(lambda: ("Submit for the first time" in self.driver.page_source))
message = self.driver.find_element_by_id("click-new-identity-tor")
assert message.is_displayed()

def _source_not_found(self):
self.driver.get(self.source_location + "/unlikely")
Expand Down

0 comments on commit 7d24c43

Please sign in to comment.