feat(auth): add bearer current user dependency
Deploy / Deploy Production (push) Failing after 2094h54m21s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 2094h55m22s
Deploy / Deploy Staging (push) Has been cancelled

This commit is contained in:
Xiaoxia AI
2026-06-21 08:35:25 +08:00
parent 2c3856a5a0
commit b084e5b468
3 changed files with 131 additions and 5 deletions
+20 -5
View File
@@ -5,6 +5,7 @@ The route layer is intentionally thin: repository construction lives in
app.dependencies and authentication behavior lives in application use cases.
"""
from app.auth import AuthenticatedUser, get_current_user
from app.config import settings
from app.dependencies import get_user_repository
from fastapi import APIRouter, Depends, HTTPException, status
@@ -49,6 +50,14 @@ class LoginResponse(BaseModel):
expires_in: int
class CurrentUserResponse(BaseModel):
user_id: str
email: str
username: str
display_name: str
email_verified: bool
@router.post("/register", response_model=RegisterResponse, status_code=status.HTTP_201_CREATED)
async def register(
request: RegisterRequest,
@@ -103,11 +112,17 @@ async def login(
)
@router.get("/me")
async def get_current_user_info():
raise HTTPException(
status_code=status.HTTP_501_NOT_IMPLEMENTED,
detail="/auth/me requires bearer-token dependency integration",
@router.get("/me", response_model=CurrentUserResponse)
async def get_current_user_info(
authenticated_user: AuthenticatedUser = Depends(get_current_user),
):
user = authenticated_user.user
return CurrentUserResponse(
user_id=user.id,
email=user.email,
username=user.username,
display_name=user.display_name,
email_verified=user.email_verified,
)