a918421945
- Remove unused imports (F401) across 17 files - Fix f-strings without placeholders (F541) in 3 files - Add noqa: E712 to SQLAlchemy == True comparisons (valid ORM pattern) - Preserve alembic side-effect import with noqa: F401 Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/pop_puller_to_gmail/sessions/99c3a25f-3479-473d-ac95-9faaa0ddd55b
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
"""User management endpoints"""
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.core.database import get_db
|
|
from app.core.deps import get_current_active_user
|
|
from app.models.database_models import User
|
|
from app.models.schemas import UserDetailResponse, UserUpdate
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/me", response_model=UserDetailResponse)
|
|
async def get_current_user_profile(
|
|
current_user: User = Depends(get_current_active_user),
|
|
):
|
|
"""Get current user profile"""
|
|
return current_user
|
|
|
|
|
|
@router.put("/me", response_model=UserDetailResponse)
|
|
async def update_current_user_profile(
|
|
user_update: UserUpdate,
|
|
current_user: User = Depends(get_current_active_user),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
"""Update current user profile"""
|
|
if user_update.email:
|
|
current_user.email = user_update.email
|
|
if user_update.full_name:
|
|
current_user.full_name = user_update.full_name
|
|
|
|
await db.commit()
|
|
await db.refresh(current_user)
|
|
return current_user
|