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:
@@ -57,6 +57,27 @@ async def init_db() -> User | None:
|
||||
await session.refresh(user)
|
||||
|
||||
logger.info(f"Created first superuser: {user.email}")
|
||||
|
||||
# Create demo user if in demo mode
|
||||
if settings.DEMO_MODE:
|
||||
demo_email = "demo@example.com"
|
||||
demo_password = "Demo123!"
|
||||
|
||||
existing_demo_user = await user_crud.get_by_email(session, email=demo_email)
|
||||
if not existing_demo_user:
|
||||
demo_user_in = UserCreate(
|
||||
email=demo_email,
|
||||
password=demo_password,
|
||||
first_name="Demo",
|
||||
last_name="User",
|
||||
is_superuser=False,
|
||||
)
|
||||
demo_user = await user_crud.create(session, obj_in=demo_user_in)
|
||||
await session.commit()
|
||||
logger.info(f"Created demo user: {demo_user.email}")
|
||||
else:
|
||||
logger.info(f"Demo user already exists: {existing_demo_user.email}")
|
||||
|
||||
return user
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user