This is the initial push of the outline of the life dashboard

This commit is contained in:
YOUNG
2026-03-09 12:52:48 -05:00
parent bf1e4e754f
commit 7596a5f382
47 changed files with 6522 additions and 3 deletions

View File

@@ -0,0 +1,37 @@
from fastapi import APIRouter, Depends, HTTPException, status
from pydantic import BaseModel
from app.auth import create_access_token, get_current_user
from app.config import settings
router = APIRouter(prefix="/api/auth", tags=["auth"])
class LoginRequest(BaseModel):
username: str
password: str
class TokenResponse(BaseModel):
access_token: str
token_type: str = "bearer"
class UserResponse(BaseModel):
username: str
@router.post("/login", response_model=TokenResponse)
def login(body: LoginRequest):
if body.username != settings.AUTH_USERNAME or body.password != settings.AUTH_PASSWORD:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid credentials",
)
token = create_access_token(body.username)
return TokenResponse(access_token=token)
@router.get("/me", response_model=UserResponse)
def me(username: str = Depends(get_current_user)):
return UserResponse(username=username)