mirror of
https://github.com/thecyberlearn/quantum-ai-v2.git
synced 2026-08-18 13:52:59 +00:00
🔧 Fix email verification 'Not Found' error
✅ Root Cause Fixed: - SITE_URL was pointing to quantumtaskai.com instead of actual Railway domain - Email verification links were going to wrong domain causing 404 errors 🔧 Changes Made: - Update SITE_URL to use quantum-ai.up.railway.app for Railway environment - Email verification links now point to correct domain 🛠️ Added Management Command: - Create verify_email command for manual email verification - Usage: python manage.py verify_email user@example.com - Useful for admin-created users or troubleshooting ✅ Expected Result: - Email verification links now work correctly - Users can successfully verify their emails - Manual verification available for admin use 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d2358fb0bb
commit
74ff5c4ea6
68
authentication/management/commands/verify_email.py
Normal file
68
authentication/management/commands/verify_email.py
Normal file
@ -0,0 +1,68 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Manually verify user email address'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('email', help='User email address to verify')
|
||||
parser.add_argument(
|
||||
'--force',
|
||||
action='store_true',
|
||||
help='Force verification even if already verified',
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
email = options['email']
|
||||
force = options['force']
|
||||
|
||||
try:
|
||||
user = User.objects.get(email=email)
|
||||
|
||||
if user.email_verified and not force:
|
||||
self.stdout.write(
|
||||
self.style.WARNING(f"Email {email} is already verified!")
|
||||
)
|
||||
self.stdout.write("Use --force to override")
|
||||
return
|
||||
|
||||
# Manually verify the email
|
||||
user.email_verified = True
|
||||
user.save()
|
||||
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(f"✅ Successfully verified email: {email}")
|
||||
)
|
||||
self.stdout.write(f"User: {user.username}")
|
||||
self.stdout.write(f"Email verified: {user.email_verified}")
|
||||
|
||||
# Clean up any existing verification tokens
|
||||
from authentication.models import EmailVerificationToken
|
||||
tokens = EmailVerificationToken.objects.filter(user=user, is_used=False)
|
||||
token_count = tokens.count()
|
||||
if token_count > 0:
|
||||
tokens.update(is_used=True)
|
||||
self.stdout.write(f"🧹 Cleaned up {token_count} unused verification tokens")
|
||||
|
||||
except User.DoesNotExist:
|
||||
self.stdout.write(
|
||||
self.style.ERROR(f"❌ User with email '{email}' not found!")
|
||||
)
|
||||
|
||||
# Show available users
|
||||
all_users = User.objects.all()
|
||||
if all_users.exists():
|
||||
self.stdout.write("\nAvailable users:")
|
||||
for user in all_users:
|
||||
status = "✅ Verified" if user.email_verified else "❌ Unverified"
|
||||
self.stdout.write(f" - {user.email} ({user.username}) - {status}")
|
||||
else:
|
||||
self.stdout.write("No users found in database")
|
||||
|
||||
except Exception as e:
|
||||
self.stdout.write(
|
||||
self.style.ERROR(f"❌ Error verifying email: {str(e)}")
|
||||
)
|
||||
@ -56,7 +56,8 @@ ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='localhost,127.0.0.1,testserver,
|
||||
|
||||
# Site URL configuration for emails
|
||||
if config('RAILWAY_ENVIRONMENT', default=''):
|
||||
SITE_URL = 'https://quantumtaskai.com'
|
||||
# Use actual Railway domain for email verification links
|
||||
SITE_URL = 'https://quantum-ai.up.railway.app'
|
||||
else:
|
||||
SITE_URL = config('SITE_URL', default='http://localhost:8000')
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user