Update web/core/views.py

This commit is contained in:
Joshua Laymon 2026-01-10 00:27:49 +00:00
parent 5a9cab4431
commit ed4618c4d0

View File

@ -54,29 +54,8 @@ EXPECTED_HEADERS = [
] ]
def login_view(request): def login_view(request):
# If Django session already exists, go straight in
if request.user.is_authenticated:
return redirect("search")
# Auto-start OIDC ONLY on a clean GET to /login/
# If ?next= is present, Django is already in a redirect flow — don't loop
if request.method == "GET" and "next" not in request.GET:
return redirect("oidc_authentication_init") return redirect("oidc_authentication_init")
# Fallback (rare): render the page so the user can click manually
ctx = {}
if request.method == "POST":
u = request.POST.get("username")
p = request.POST.get("password")
user = authenticate(request, username=u, password=p)
if user:
login(request, user)
return redirect("search")
ctx["error"] = "Invalid credentials"
return render(request, "login.html", ctx)