Add files via upload

This commit is contained in:
Egor
2026-01-25 09:43:49 +03:00
committed by GitHub
parent 7b42bfd02d
commit 9578a91a9e
2 changed files with 54 additions and 4 deletions
+5 -4
View File
@@ -297,8 +297,8 @@ async def register_email(
# Send verification email asynchronously (smtplib is blocking)
if settings.is_cabinet_email_verification_enabled() and email_service.is_configured():
# TODO: Get actual verification URL from settings
verification_url = 'https://example.com/cabinet/verify-email'
cabinet_url = getattr(settings, 'CABINET_URL', 'https://example.com/cabinet')
verification_url = f'{cabinet_url}/verify-email'
await asyncio.to_thread(
email_service.send_verification_email,
to_email=request.email,
@@ -391,7 +391,7 @@ async def register_email_standalone(
# Отправить email верификации
if settings.is_cabinet_email_verification_enabled() and email_service.is_configured():
cabinet_url = getattr(settings, 'CABINET_URL', 'https://example.com/cabinet')
verification_url = f'{cabinet_url}/verify-email?token={verification_token}'
verification_url = f'{cabinet_url}/verify-email'
await asyncio.to_thread(
email_service.send_verification_email,
to_email=request.email,
@@ -485,7 +485,8 @@ async def resend_verification(
# Send verification email asynchronously (smtplib is blocking)
if settings.is_cabinet_email_verification_enabled() and email_service.is_configured():
verification_url = 'https://example.com/cabinet/verify-email'
cabinet_url = getattr(settings, 'CABINET_URL', 'https://example.com/cabinet')
verification_url = f'{cabinet_url}/verify-email'
await asyncio.to_thread(
email_service.send_verification_email,
to_email=user.email,
+49
View File
@@ -32,6 +32,7 @@ THEME_COLORS_KEY = 'CABINET_THEME_COLORS' # Stores JSON with theme colors
ENABLED_THEMES_KEY = 'CABINET_ENABLED_THEMES' # Stores JSON with enabled themes {"dark": true, "light": false}
ANIMATION_ENABLED_KEY = 'CABINET_ANIMATION_ENABLED' # Stores "true" or "false"
FULLSCREEN_ENABLED_KEY = 'CABINET_FULLSCREEN_ENABLED' # Stores "true" or "false"
EMAIL_AUTH_ENABLED_KEY = 'CABINET_EMAIL_AUTH_ENABLED' # Stores "true" or "false"
# Allowed image types
ALLOWED_CONTENT_TYPES = {'image/png', 'image/jpeg', 'image/jpg', 'image/webp', 'image/svg+xml'}
@@ -128,6 +129,18 @@ class FullscreenEnabledUpdate(BaseModel):
enabled: bool
class EmailAuthEnabledResponse(BaseModel):
"""Email auth enabled setting."""
enabled: bool = True
class EmailAuthEnabledUpdate(BaseModel):
"""Request to update email auth setting."""
enabled: bool
# Default theme colors
DEFAULT_THEME_COLORS = {
'accent': '#3b82f6',
@@ -586,3 +599,39 @@ async def update_fullscreen_enabled(
logger.info(f'Admin {admin.telegram_id} set fullscreen enabled: {payload.enabled}')
return FullscreenEnabledResponse(enabled=payload.enabled)
# ============ Email Auth Routes ============
@router.get('/email-auth', response_model=EmailAuthEnabledResponse)
async def get_email_auth_enabled(
db: AsyncSession = Depends(get_cabinet_db),
):
"""
Get email auth enabled setting.
This is a public endpoint - no authentication required.
Controls whether email registration/login is available.
"""
email_auth_value = await get_setting_value(db, EMAIL_AUTH_ENABLED_KEY)
if email_auth_value is not None:
enabled = email_auth_value.lower() == 'true'
return EmailAuthEnabledResponse(enabled=enabled)
# Default: check config setting
return EmailAuthEnabledResponse(enabled=settings.is_cabinet_email_auth_enabled())
@router.patch('/email-auth', response_model=EmailAuthEnabledResponse)
async def update_email_auth_enabled(
payload: EmailAuthEnabledUpdate,
admin: User = Depends(get_current_admin_user),
db: AsyncSession = Depends(get_cabinet_db),
):
"""Update email auth enabled setting. Admin only."""
await set_setting_value(db, EMAIL_AUTH_ENABLED_KEY, str(payload.enabled).lower())
logger.info(f'Admin {admin.telegram_id} set email auth enabled: {payload.enabled}')
return EmailAuthEnabledResponse(enabled=payload.enabled)