Enable demo mode features, auto-fill demo credentials, and enhance branding integration
- Added `DEMO_MODE` to backend configuration with relaxed security support for specific demo accounts. - Updated password validators to allow predefined weak passwords in demo mode. - Auto-fill login forms with demo credentials via query parameters for improved demo accessibility. - Introduced demo user creation logic during database initialization if `DEMO_MODE` is enabled. - Replaced `img` tags with `next/image` for consistent and optimized visuals in branding elements. - Refined footer, header, and layout components to incorporate improved logo handling.
This commit is contained in:
@@ -14,6 +14,10 @@ class Settings(BaseSettings):
|
||||
default="development",
|
||||
description="Environment: development, staging, or production",
|
||||
)
|
||||
DEMO_MODE: bool = Field(
|
||||
default=False,
|
||||
description="Enable demo mode (relaxed security, demo users)",
|
||||
)
|
||||
|
||||
# Security: Content Security Policy
|
||||
# Set to False to disable CSP entirely (not recommended)
|
||||
@@ -110,11 +114,21 @@ class Settings(BaseSettings):
|
||||
|
||||
@field_validator("FIRST_SUPERUSER_PASSWORD")
|
||||
@classmethod
|
||||
def validate_superuser_password(cls, v: str | None) -> str | None:
|
||||
def validate_superuser_password(cls, v: str | None, info) -> str | None:
|
||||
"""Validate superuser password strength."""
|
||||
if v is None:
|
||||
return v
|
||||
|
||||
# Get environment from values if available
|
||||
values_data = info.data if info.data else {}
|
||||
demo_mode = values_data.get("DEMO_MODE", False)
|
||||
|
||||
if demo_mode:
|
||||
# In demo mode, allow specific weak passwords for demo accounts
|
||||
demo_passwords = {"Demo123!", "Admin123!"}
|
||||
if v in demo_passwords:
|
||||
return v
|
||||
|
||||
if len(v) < 12:
|
||||
raise ValueError("FIRST_SUPERUSER_PASSWORD must be at least 12 characters")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user