Display a flash message when a user logs out
This commit is contained in:
parent
227feab972
commit
c653cf2dbf
@ -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):
|
||||
|
@ -193,6 +193,13 @@ MESSAGES = {
|
||||
""",
|
||||
"category": "success",
|
||||
},
|
||||
"logged_out": {
|
||||
"title_template": translate("flash.logged_out"),
|
||||
"message_template": """
|
||||
You've been logged out.
|
||||
""",
|
||||
"category": "info",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user