From 825ebd874e20cefa83a87f32960ec520758373cc Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 22 Oct 2021 12:01:30 +0700 Subject: [PATCH] handle next url parameter in login --- tubearchivist/home/templates/home/login.html | 1 + tubearchivist/home/views.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tubearchivist/home/templates/home/login.html b/tubearchivist/home/templates/home/login.html index d7bfed5..5e2c23d 100644 --- a/tubearchivist/home/templates/home/login.html +++ b/tubearchivist/home/templates/home/login.html @@ -29,6 +29,7 @@ {% for field in form %} {{ field }}
{% endfor %} + diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 0f568d5..1c16844 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -161,10 +161,13 @@ class LoginView(View): """handle login post request""" form = AuthenticationForm(data=request.POST) if form.is_valid(): + next_url = request.POST.get('next') or "home" + print(f"next url: {next_url}") user = form.get_user() login(request, user) + return redirect(next_url) - return redirect("/") + return redirect("login") @staticmethod def read_config():