From 6eb277c701a5de12f3ee49a7f6cd8f1576ea5a5f Mon Sep 17 00:00:00 2001 From: Keith Smith Date: Fri, 26 Dec 2025 17:14:46 -0700 Subject: [PATCH] Fix authentication: allow superusers to bypass email verification and approval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The authentication backend was requiring ALL users (including superusers) to have email_verified=True and is_approved=True. This created a chicken-and-egg problem where the first superuser couldn't log in to approve themselves. Now superusers bypass these checks and can log in immediately after creation via createsuperuser command. Regular users still require email verification and admin approval. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- users/backends.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/users/backends.py b/users/backends.py index c45d5d2..8fd6081 100644 --- a/users/backends.py +++ b/users/backends.py @@ -27,7 +27,11 @@ class EmailVerifiedApprovedBackend(ModelBackend): if user is None: return None - # Check email verification + # Superusers bypass email verification and approval checks + if user.is_superuser: + return user + + # Check email verification for regular users if not user.email_verified: # Store reason for failed login (for web UI) if request: @@ -35,7 +39,7 @@ class EmailVerifiedApprovedBackend(ModelBackend): request.session['login_email'] = user.email return None - # Check admin approval + # Check admin approval for regular users if not user.is_approved: if request: request.session['login_error'] = 'not_approved'