kopia lustrzana https://github.com/simonw/datasette
Add message when user logs out, refs #840
rodzic
16f592247a
commit
51427323e6
|
@ -86,6 +86,7 @@ class LogoutView(BaseView):
|
|||
async def post(self, request):
|
||||
response = Response.redirect("/")
|
||||
response.set_cookie("ds_actor", "", expires=0, max_age=0)
|
||||
self.ds.add_message(request, "You are now logged out", self.ds.WARNING)
|
||||
return response
|
||||
|
||||
|
||||
|
|
|
@ -97,7 +97,8 @@ class TestResponse:
|
|||
@property
|
||||
def cookies(self):
|
||||
cookie = SimpleCookie()
|
||||
cookie.load(self.headers.get("set-cookie") or "")
|
||||
for header in self.headers.getlist("set-cookie"):
|
||||
cookie.load(header)
|
||||
return {key: value.value for key, value in cookie.items()}
|
||||
|
||||
@property
|
||||
|
|
|
@ -74,5 +74,7 @@ def test_logout(app_client):
|
|||
cookies={"ds_actor": app_client.actor_cookie({"id": "test"})},
|
||||
allow_redirects=False,
|
||||
)
|
||||
assert {"ds_actor": ""} == response4.cookies
|
||||
assert 302 == response4.status
|
||||
assert "" == response4.cookies["ds_actor"]
|
||||
# Should also have set a message
|
||||
messages = app_client.ds.unsign(response4.cookies["ds_messages"], "messages")
|
||||
assert [["You are now logged out", 2]] == messages
|
||||
|
|
Ładowanie…
Reference in New Issue