Initial commit: XDL Twitter/X video downloader

This commit is contained in:
mini
2026-02-18 17:15:12 +08:00
commit 7fdd181728
32 changed files with 1230 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
"""Authentication routes."""
import os
from fastapi import APIRouter, HTTPException, status
from app.schemas import LoginRequest, TokenResponse
from app.auth import create_access_token
router = APIRouter(prefix="/api/auth", tags=["auth"])
ADMIN_USERNAME = os.getenv("ADMIN_USERNAME", "admin")
ADMIN_PASSWORD = os.getenv("ADMIN_PASSWORD", "admin")
@router.post("/login", response_model=TokenResponse)
async def login(req: LoginRequest):
if req.username != ADMIN_USERNAME or req.password != ADMIN_PASSWORD:
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid credentials")
token = create_access_token({"sub": req.username})
return TokenResponse(access_token=token)