diff --git a/freedoi/accounts/urls.py b/freedoi/accounts/urls.py index c664fc9..ba0bdaa 100644 --- a/freedoi/accounts/urls.py +++ b/freedoi/accounts/urls.py @@ -1,7 +1,6 @@ from django.urls import path -from django.contrib.auth import views as auth_views from django.views.generic import TemplateView -from .views import SendLoginEmailView, LoginView +from .views import SendLoginEmailView, LoginView, LogoutView urlpatterns = [ path("login///", LoginView.as_view(), name="login"), @@ -10,7 +9,7 @@ urlpatterns = [ SendLoginEmailView.as_view(), name="login", ), - path("logout/", auth_views.LogoutView.as_view(next_page="/"), name="logout"), + path("logout/", LogoutView.as_view(), name="logout"), path( "email-sent/", TemplateView.as_view(template_name="accounts/email_sent.html"), diff --git a/freedoi/accounts/views.py b/freedoi/accounts/views.py index c4d85a6..9b1d933 100644 --- a/freedoi/accounts/views.py +++ b/freedoi/accounts/views.py @@ -2,11 +2,11 @@ from django.contrib.auth import get_user_model, login as auth_login from django.core.mail import send_mail from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode from django.utils.encoding import force_bytes, force_str -from django.template.loader import render_to_string from django.http import HttpResponse from django.shortcuts import redirect from django.views.generic import FormView, View from django.contrib.auth.tokens import default_token_generator +from django.contrib.auth import logout from .forms import EmailForm User = get_user_model() @@ -48,3 +48,9 @@ class LoginView(View): return redirect("home") else: return HttpResponse("Login link is invalid") + + +class LogoutView(View): + def get(self, request): + logout(request) + return redirect("home") \ No newline at end of file