mirror of
https://github.com/thecyberlearn/quantum-ai-v3.git
synced 2026-08-18 08:52:58 +00:00
🔐 Add email verification bypass for testing environments
- Add REQUIRE_EMAIL_VERIFICATION setting (default: True) - Skip email verification when setting is False - Auto-verify users and provide welcome bonus when bypassed - Updated .env.example with documentation - Allows testing on Railway without email setup until final domain Perfect for Railway deployment until email/domain configuration is ready. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
7120bfdf98
commit
7f3b678d39
@ -4,6 +4,10 @@ DEBUG=True
|
|||||||
ALLOWED_HOSTS=localhost,127.0.0.1,your-domain.com
|
ALLOWED_HOSTS=localhost,127.0.0.1,your-domain.com
|
||||||
CSRF_TRUSTED_ORIGINS=http://localhost:8000,http://127.0.0.1:8000
|
CSRF_TRUSTED_ORIGINS=http://localhost:8000,http://127.0.0.1:8000
|
||||||
|
|
||||||
|
# Email Verification
|
||||||
|
# Set to False to bypass email verification for testing (until final domain is ready)
|
||||||
|
REQUIRE_EMAIL_VERIFICATION=True
|
||||||
|
|
||||||
# Database Configuration
|
# Database Configuration
|
||||||
# Default: SQLite (simple, reliable, no setup required)
|
# Default: SQLite (simple, reliable, no setup required)
|
||||||
# Railway: Automatically uses PostgreSQL via DATABASE_URL
|
# Railway: Automatically uses PostgreSQL via DATABASE_URL
|
||||||
|
|||||||
@ -101,8 +101,8 @@ def login_view(request):
|
|||||||
|
|
||||||
user = authenticate(request, username=email, password=password)
|
user = authenticate(request, username=email, password=password)
|
||||||
if user is not None:
|
if user is not None:
|
||||||
# Check if email is verified
|
# Check if email is verified (only if email verification is required)
|
||||||
if not user.email_verified:
|
if settings.REQUIRE_EMAIL_VERIFICATION and not user.email_verified:
|
||||||
messages.warning(request, 'Please verify your email address before logging in. Check your inbox for the verification link.')
|
messages.warning(request, 'Please verify your email address before logging in. Check your inbox for the verification link.')
|
||||||
return render(request, 'authentication/login.html')
|
return render(request, 'authentication/login.html')
|
||||||
|
|
||||||
@ -154,15 +154,28 @@ def register_view(request):
|
|||||||
email=email,
|
email=email,
|
||||||
password=password1
|
password=password1
|
||||||
)
|
)
|
||||||
# Don't automatically login - require email verification first
|
|
||||||
|
|
||||||
# Send verification email
|
# Handle email verification based on settings
|
||||||
if send_verification_email(user):
|
if settings.REQUIRE_EMAIL_VERIFICATION:
|
||||||
messages.success(request, 'Account created successfully! Please check your email to verify your account.')
|
# Don't automatically login - require email verification first
|
||||||
|
# Send verification email
|
||||||
|
if send_verification_email(user):
|
||||||
|
messages.success(request, 'Account created successfully! Please check your email to verify your account.')
|
||||||
|
else:
|
||||||
|
messages.warning(request, 'Account created but verification email could not be sent. You can request a new one after logging in.')
|
||||||
|
|
||||||
|
return redirect('authentication:login')
|
||||||
else:
|
else:
|
||||||
messages.warning(request, 'Account created but verification email could not be sent. You can request a new one after logging in.')
|
# Skip email verification - auto-verify and login
|
||||||
|
user.email_verified = True
|
||||||
|
user.save()
|
||||||
|
|
||||||
return redirect('authentication:login')
|
# Add initial wallet balance for new users
|
||||||
|
user.add_balance(50, "Welcome bonus - 50 AED to get started!")
|
||||||
|
|
||||||
|
login(request, user)
|
||||||
|
messages.success(request, f'Welcome {user.username}! Your account has been created and you\'ve received 50 AED welcome bonus.')
|
||||||
|
return redirect('core:homepage')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error creating account for {email}: {str(e)}")
|
logger.error(f"Error creating account for {email}: {str(e)}")
|
||||||
messages.error(request, 'Error creating account')
|
messages.error(request, 'Error creating account')
|
||||||
|
|||||||
@ -61,6 +61,10 @@ if config('RAILWAY_ENVIRONMENT', default=''):
|
|||||||
else:
|
else:
|
||||||
SITE_URL = config('SITE_URL', default='http://localhost:8000')
|
SITE_URL = config('SITE_URL', default='http://localhost:8000')
|
||||||
|
|
||||||
|
# Email verification requirement
|
||||||
|
# Set to False for testing environments until final domain is ready
|
||||||
|
REQUIRE_EMAIL_VERIFICATION = config('REQUIRE_EMAIL_VERIFICATION', default=True, cast=bool)
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user