kopia lustrzana https://github.com/simonw/datasette
Only show 'log out' if ds_cookie present, closes #884
rodzic
f7c3fc978c
commit
1bae24691f
|
@ -739,6 +739,7 @@ class Datasette:
|
||||||
**{
|
**{
|
||||||
"actor": request.actor if request else None,
|
"actor": request.actor if request else None,
|
||||||
"display_actor": display_actor,
|
"display_actor": display_actor,
|
||||||
|
"show_logout": "ds_actor" in request.cookies,
|
||||||
"app_css_hash": self.app_css_hash(),
|
"app_css_hash": self.app_css_hash(),
|
||||||
"zip": zip,
|
"zip": zip,
|
||||||
"body_scripts": body_scripts,
|
"body_scripts": body_scripts,
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
<nav class="hd">{% block nav %}
|
<nav class="hd">{% block nav %}
|
||||||
{% if actor %}
|
{% if actor %}
|
||||||
<div class="logout">
|
<div class="logout">
|
||||||
<strong>{{ display_actor(actor) }}</strong> ·
|
<strong>{{ display_actor(actor) }}</strong>{% if show_logout %} ·
|
||||||
<form action="/-/logout" method="post">
|
<form action="/-/logout" method="post">
|
||||||
<input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
|
<input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
|
||||||
<button class="button-as-link">Log out</button>
|
<button class="button-as-link">Log out</button>
|
||||||
</form>
|
</form>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}</nav>
|
{% endblock %}</nav>
|
||||||
|
|
|
@ -92,3 +92,11 @@ def test_logout_button_in_navigation(app_client, path):
|
||||||
):
|
):
|
||||||
assert fragment in response.text
|
assert fragment in response.text
|
||||||
assert fragment not in anon_response.text
|
assert fragment not in anon_response.text
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("path", ["/", "/fixtures", "/fixtures/facetable"])
|
||||||
|
def test_no_logout_button_in_navigation_if_no_ds_actor_cookie(app_client, path):
|
||||||
|
response = app_client.get(path + "?_bot=1")
|
||||||
|
assert "<strong>bot</strong>" in response.text
|
||||||
|
assert "<strong>bot</strong> ·" not in response.text
|
||||||
|
assert '<form action="/-/logout" method="post">' not in response.text
|
||||||
|
|
Ładowanie…
Reference in New Issue