diff --git a/atst/domain/auth.py b/atst/domain/auth.py index 1737763f..370d33e0 100644 --- a/atst/domain/auth.py +++ b/atst/domain/auth.py @@ -1,6 +1,7 @@ from flask import g, redirect, url_for, session, request from atst.domain.users import Users +from atst.utils.flash import formatted_flash UNPROTECTED_ROUTES = [ @@ -60,6 +61,7 @@ def logout(): if session.get("user_id"): # pragma: no branch del session["user_id"] del session["last_login"] + formatted_flash("logged_out") def _unprotected_route(request): diff --git a/atst/utils/flash.py b/atst/utils/flash.py index 001293af..dc63dcd2 100644 --- a/atst/utils/flash.py +++ b/atst/utils/flash.py @@ -193,6 +193,13 @@ MESSAGES = { """, "category": "success", }, + "logged_out": { + "title_template": translate("flash.logged_out"), + "message_template": """ + You've been logged out. + """, + "category": "info", + }, } diff --git a/tests/test_auth.py b/tests/test_auth.py index 9d89697a..6af412f4 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -202,6 +202,20 @@ def test_logout(app, client, monkeypatch): assert destination == url_for("atst.root") +def test_logging_out_creates_a_flash_message(app, client, monkeypatch): + monkeypatch.setattr( + "atst.domain.authnid.AuthenticationContext.authenticate", lambda s: True + ) + monkeypatch.setattr( + "atst.domain.authnid.AuthenticationContext.get_user", + lambda s: UserFactory.create(), + ) + _login(client) + logout_response = client.get(url_for("atst.logout"), follow_redirects=True) + + assert "Logged out" in logout_response.data.decode() + + def test_redirected_on_login(client, monkeypatch): monkeypatch.setattr( "atst.domain.authnid.AuthenticationContext.authenticate", lambda *args: True diff --git a/translations.yaml b/translations.yaml index d7cb4329..20731601 100644 --- a/translations.yaml +++ b/translations.yaml @@ -81,6 +81,7 @@ flash: success: Success! new_application_member: 'You have successfully invited {user_name} to the team.' updated_application_team_settings: 'You have updated the {application_name} team settings.' + logged_out: Logged out footer: about_link_text: Joint Enterprise Defense Infrastructure browser_support: JEDI Cloud supported on these web browsers