first commit

This commit is contained in:
2026-03-05 11:50:15 +08:00
commit b1b14fd964
45 changed files with 7779 additions and 0 deletions

13
backend/routers/auth.py Normal file
View File

@@ -0,0 +1,13 @@
from fastapi import APIRouter, HTTPException, status
from backend.auth import create_access_token, verify_password
from backend.schemas import LoginRequest, Token
router = APIRouter()
@router.post("/login", response_model=Token)
def login(payload: LoginRequest) -> Token:
if not verify_password(payload.username, payload.password):
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="用户名或密码错误")
return Token(access_token=create_access_token(payload.username))