Keep GET parameters on OTP login

This commit is contained in:
Kumi 2022-08-05 08:03:29 +02:00
parent 5c4325d57d
commit 2c09055821
Signed by: kumi
GPG key ID: 5D1CE6AF1805ECA2
2 changed files with 3 additions and 2 deletions

View file

@ -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)

View file

@ -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"))),