diff --git a/web/core/views.py b/web/core/views.py index 29a5973..f75dc77 100644 --- a/web/core/views.py +++ b/web/core/views.py @@ -54,19 +54,16 @@ EXPECTED_HEADERS = [ ] def login_view(request): - # If Django session already exists, go to app + # If Django session already exists, go straight in if request.user.is_authenticated: return redirect("search") - # Only auto-start OIDC if this is a fresh browser visit - # and NOT a redirect coming from Django itself - if ( - request.method == "GET" - and "next" not in request.GET - ): + # 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") - # Fallback: show login page (rare, but prevents loops) + # Fallback (rare): render the page so the user can click manually ctx = {} if request.method == "POST": @@ -82,6 +79,7 @@ def login_view(request): + def is_admin(user): return user.is_superuser or user.is_staff