Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remplace la vue de logout par la LogoutView de Django #6272

Merged
merged 2 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions zds/member/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib.auth.views import LogoutView
from django.urls import re_path, path

from zds.member.views import MemberList
Expand All @@ -16,7 +17,7 @@
member_from_ip,
modify_profile,
)
from zds.member.views.login import login_view, logout_view
from zds.member.views.login import login_view
from zds.member.views.hats import (
HatsSettings,
RequestedHatsList,
Expand Down Expand Up @@ -103,7 +104,7 @@
re_path(r"^casquettes/retirer/(?P<user_pk>\d+)/(?P<hat_pk>\d+)/$", remove_hat, name="remove-hat"),
# membership
re_path(r"^connexion/$", login_view, name="member-login"),
re_path(r"^deconnexion/$", logout_view, name="member-logout"),
re_path(r"^deconnexion/$", LogoutView.as_view(), name="member-logout"),
re_path(r"^inscription/$", RegisterView.as_view(), name="register-member"),
re_path(r"^reinitialisation/$", forgot_password, name="member-forgot-password"),
re_path(r"^validation/$", SendValidationEmailView.as_view(), name="send-validation-email"),
Expand Down
15 changes: 1 addition & 14 deletions zds/member/views/login.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from django.contrib import messages
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth import authenticate, login
from django.contrib.auth.models import User
from django.template.context_processors import csrf
from django.urls import reverse, resolve, Resolver404, NoReverseMatch
from django.shortcuts import redirect, render, get_object_or_404
from django.utils.translation import gettext_lazy as _
from django.views.decorators.http import require_POST

from zds.member.forms import LoginForm
from zds.member.models import Profile
Expand Down Expand Up @@ -101,14 +99,3 @@ def login_view(request):
csrf_tk["error"] = error
csrf_tk["form"] = form
return render(request, "member/login.html", {"form": form, "csrf_tk": csrf_tk})


@login_required
@require_POST
def logout_view(request):
"""Log user out."""

logout(request)
request.session.clear()
response = redirect(reverse("homepage"))
return response
2 changes: 2 additions & 0 deletions zds/settings/abstract_base/zds.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

zds_config = config.get("zds", {})

LOGOUT_REDIRECT_URL = "homepage"

GEOIP_PATH = str(BASE_DIR / "geodata")
GEOIP_CITY = "GeoLite2-City.mmdb"

Expand Down