Skip to content

Commit

Permalink
prevent logged users to re-log (WIP, tests missing)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Nov 7, 2024
1 parent 33dc422 commit 2b8ddfe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lacommunaute/forum_member/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.contrib.auth.tokens import default_token_generator
from django.core.mail import send_mail
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.shortcuts import redirect, render
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.encoding import force_bytes, force_str
Expand Down Expand Up @@ -79,6 +79,12 @@ class LoginView(FormView):
template_name = "registration/login_with_magic_link.html"
form_class = LoginForm

def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated:
next_url = request.GET.get("next", "/")
return redirect(next_url)
return super().dispatch(request, *args, **kwargs)

def get_context_data(self, **kwargs):
return super().get_context_data(**kwargs) | {"next": self.request.GET.get("next", "/")}

Expand Down

0 comments on commit 2b8ddfe

Please sign in to comment.