Merge pull request #1235 from umap-project/logout-redirect
Adapt logout behaviour in ajax/not ajax modes
This commit is contained in:
commit
f94a513c4a
2 changed files with 21 additions and 1 deletions
|
@ -261,3 +261,21 @@ def test_user_dashboard_display_user_maps(client, map):
|
||||||
assert f"{map.get_absolute_url()}?download" in body
|
assert f"{map.get_absolute_url()}?download" in body
|
||||||
assert "Everyone (public)" in body
|
assert "Everyone (public)" in body
|
||||||
assert "Owner only" in body
|
assert "Owner only" in body
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_logout_should_return_json_in_ajax(client, user, settings):
|
||||||
|
client.login(username=user.username, password="123123")
|
||||||
|
response = client.get(
|
||||||
|
reverse("logout"), headers={"X_REQUESTED_WITH": "XMLHttpRequest"}
|
||||||
|
)
|
||||||
|
data = json.loads(response.content.decode())
|
||||||
|
assert data["redirect"] == "/"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_logout_should_return_redirect(client, user, settings):
|
||||||
|
client.login(username=user.username, password="123123")
|
||||||
|
response = client.get(reverse("logout"))
|
||||||
|
assert response.status_code == 302
|
||||||
|
assert response["Location"] == "/"
|
||||||
|
|
|
@ -945,7 +945,9 @@ def stats(request):
|
||||||
|
|
||||||
def logout(request):
|
def logout(request):
|
||||||
do_logout(request)
|
do_logout(request)
|
||||||
return simple_json_response(redirect="/")
|
if is_ajax(request):
|
||||||
|
return simple_json_response(redirect="/")
|
||||||
|
return HttpResponseRedirect("/")
|
||||||
|
|
||||||
|
|
||||||
class LoginPopupEnd(TemplateView):
|
class LoginPopupEnd(TemplateView):
|
||||||
|
|
Loading…
Reference in a new issue