Update web/core/views.py
This commit is contained in:
parent
c0acced574
commit
1ada8e4fa2
@ -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):
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user