feat: phase 1C JWT UI, events/hosts API, Vue frontend

This commit is contained in:
2026-05-26 21:46:34 +10:00
parent d8a8329397
commit bdfc7016e6
27 changed files with 2498 additions and 23 deletions
+31
View File
@@ -0,0 +1,31 @@
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel
from app.auth.jwt_auth import create_access_token
from app.config import get_settings
router = APIRouter(prefix="/auth", tags=["auth"])
class LoginRequest(BaseModel):
username: str
password: str
class TokenResponse(BaseModel):
access_token: str
token_type: str = "bearer"
@router.post("/login", response_model=TokenResponse)
def login(body: LoginRequest) -> TokenResponse:
settings = get_settings()
if not settings.sac_admin_password:
raise HTTPException(
status_code=503,
detail="SAC_ADMIN_PASSWORD is not configured",
)
if body.username != settings.sac_admin_username or body.password != settings.sac_admin_password:
raise HTTPException(status_code=401, detail="Invalid username or password")
token = create_access_token(body.username)
return TokenResponse(access_token=token)