Fix: login redirect to use the

next get var form url
This commit is contained in:
Aroy-Art 2023-12-06 20:08:08 +01:00
parent 73b4e26372
commit a210588452
Signed by: Aroy
GPG key ID: DB9689E9391DD156

View file

@ -11,8 +11,8 @@ from .forms import LoginForm, SignUpForm
def login_view(request):
if request.user.is_authenticated:
# User is already logged in, redirect them to the home page
return redirect('/')
next_page = request.GET.get('next', '/')
return redirect(next_page)
form = LoginForm(request.POST or None)
msg = None
@ -25,7 +25,8 @@ def login_view(request):
user = authenticate(username=username, password=password)
if user is not None:
login(request, user)
return redirect("/")
next_page = request.GET.get('next', '/')
return redirect(next_page)
else:
msg = 'Invalid credentials'
else: