From 2c090558217244adf13614dd672cb8e2e5ac90f3 Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 5 Aug 2022 08:03:29 +0200 Subject: [PATCH] Keep GET parameters on OTP login --- authentication/views/login.py | 3 ++- kumidc/urls.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/authentication/views/login.py b/authentication/views/login.py index 81be39e..1c4b3ac 100644 --- a/authentication/views/login.py +++ b/authentication/views/login.py @@ -18,7 +18,8 @@ class LoginView(OnlyLoggedOutMixin, TitleMixin, DjangoLoginView): if has_otp(user := form.get_user()): session = AuthSession.objects.create(user=user) self.request.session["AuthSession"] = str(session.id) - return HttpResponseRedirect(reverse_lazy("auth:totplogin")) + attrs = ("?" + self.request.GET.urlencode()) if self.request.GET else "" + return HttpResponseRedirect(reverse_lazy("auth:totplogin") + attrs) self.request.session["LastActivity"] = timezone.now().timestamp() return super().form_valid(form) diff --git a/kumidc/urls.py b/kumidc/urls.py index 8e1b9f6..751809b 100644 --- a/kumidc/urls.py +++ b/kumidc/urls.py @@ -4,7 +4,7 @@ from django.views.generic import RedirectView urlpatterns = [ - path('admin/login/', RedirectView.as_view(url=reverse_lazy("auth:login", query_string=True))), + path('admin/login/', RedirectView.as_view(url=reverse_lazy("auth:login"), query_string=True)), path('admin/', admin.site.urls), re_path(r'^openid/', include('oidc_provider.urls', namespace='oidc_provider')), path('auth/', include(("authentication.urls", "auth"))),