feat(auth): подтверждение email + актуализация SMTP/Ollama конфигов
- Резенд письма верификации (/auth/resend-verification), модалка на фронте с поллингом статуса, страница /verify-email/:token - SMTP переведён на собственный Postfix (mail.jze9mail.ru, STARTTLS, SMTP_TLS_VERIFY) вместо Yandex-заглушки в дефолтах и .env.example - OLLAMA_URL и модель в worker-gpu синхронизированы с новым GPU-хостом (llama3:8b -> qwen2.5:7b, которой раньше не было на сервере) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -98,6 +98,37 @@ async def get_me(current_user: User = Depends(get_current_user)) -> UserInToken:
|
||||
return UserInToken.model_validate(current_user)
|
||||
|
||||
|
||||
@router.post("/resend-verification", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def resend_verification(
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> None:
|
||||
"""Повторно отправить письмо с подтверждением email."""
|
||||
if current_user.is_verified:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Email уже подтверждён",
|
||||
)
|
||||
|
||||
if not current_user.verification_token:
|
||||
current_user.verification_token = secrets.token_urlsafe(32)
|
||||
await db.commit()
|
||||
await db.refresh(current_user)
|
||||
|
||||
try:
|
||||
celery_app.send_task(
|
||||
"notify.send_verification",
|
||||
args=[current_user.email, current_user.name, current_user.verification_token],
|
||||
queue="queue.notify",
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"Не удалось поставить задачу повторной верификации: {e}")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="Не удалось отправить письмо, попробуйте позже",
|
||||
)
|
||||
|
||||
|
||||
@router.post("/verify-email/{token}", status_code=status.HTTP_200_OK)
|
||||
async def verify_email(token: str, db: AsyncSession = Depends(get_db)) -> dict:
|
||||
"""Подтвердить email по токену из письма."""
|
||||
|
||||
@@ -45,11 +45,12 @@ class Settings(BaseSettings):
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES: int = 10080 # 7 дней
|
||||
|
||||
# SMTP
|
||||
SMTP_HOST: str = "smtp.yandex.ru"
|
||||
SMTP_PORT: int = 465
|
||||
SMTP_USER: str = "noreply@jze9.ru"
|
||||
SMTP_HOST: str = "mail.jze9mail.ru"
|
||||
SMTP_PORT: int = 587
|
||||
SMTP_USER: str = "noreply"
|
||||
SMTP_PASSWORD: str = "changeme"
|
||||
SMTP_FROM: str = "noreply@jze9.ru"
|
||||
SMTP_FROM: str = "noreply@jze9mail.ru"
|
||||
SMTP_TLS_VERIFY: bool = True
|
||||
|
||||
# App
|
||||
APP_URL: str = "https://academic.jze9.ru"
|
||||
|
||||
Reference in New Issue
Block a user