diff --git a/lelcsc/core/urls.py b/lelcsc/core/urls.py index de3f2b7..f0603f3 100644 --- a/lelcsc/core/urls.py +++ b/lelcsc/core/urls.py @@ -5,4 +5,5 @@ from . import views urlpatterns = [ path("", views.index, name="index"), path("unauthorized", views.unauthorized, name="unauthorized"), + path("admin/login/", views.admin_login), ] diff --git a/lelcsc/core/views.py b/lelcsc/core/views.py index ad16628..d613d1e 100644 --- a/lelcsc/core/views.py +++ b/lelcsc/core/views.py @@ -1,5 +1,7 @@ from django.contrib.auth.decorators import login_required -from django.shortcuts import render +from django.http import QueryDict +from django.shortcuts import redirect, render +from django.urls import reverse @login_required @@ -9,3 +11,13 @@ def index(request): def unauthorized(request): return render(request, "core/unauthorized.html", {}) + + +def admin_login(request): + query = "" + if next := request.GET.get("next"): + q = QueryDict(mutable=True) + q["next"] = next + query = f"?{q.urlencode()}" + + return redirect(f"{reverse('oidc_authentication_init')}{query}")