From 1ada8e4fa28e37f9496215f147bce332ae3f1bb0 Mon Sep 17 00:00:00 2001 From: Joshua Laymon Date: Sat, 10 Jan 2026 00:05:14 +0000 Subject: [PATCH] Update web/core/views.py --- web/core/views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/core/views.py b/web/core/views.py index 315baa1..d183093 100644 --- a/web/core/views.py +++ b/web/core/views.py @@ -14,6 +14,7 @@ from django.urls import reverse from django.views.decorators.cache import never_cache from django.views.decorators.http import require_POST from .models_user import SearchHistory, ViewedIllustration +from django.conf import settings from .forms import ImportForm, EntryForm from .models import Entry @@ -59,8 +60,16 @@ def is_admin(user): def login_view(request): + # Already logged into Django if request.user.is_authenticated: return redirect("search") + + # Pangolin + Authentik already authenticated the user at the proxy layer + # → immediately initiate OIDC login + if request.method == "GET": + return redirect("oidc_authentication_init") + + # Fallback: local username/password login (optional) ctx = {} if request.method == "POST": u = request.POST.get("username") @@ -70,8 +79,8 @@ def login_view(request): login(request, user) return redirect("search") ctx["error"] = "Invalid credentials" - return render(request, "login.html", ctx) + return render(request, "login.html", ctx) def entry_context(entry, result_ids): """