
Features: - JWT authentication with user registration and login - Customer management with full CRUD operations - Invoice management with automatic calculations - Multi-tenant data isolation by user - SQLite database with Alembic migrations - RESTful API with comprehensive documentation - Tax calculations and invoice status tracking - Code formatted with Ruff linting
32 lines
945 B
Python
32 lines
945 B
Python
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from sqlalchemy.orm import Session
|
|
from app.db.session import get_db
|
|
from app.services.user_service import UserService
|
|
from app.schemas.user import User, UserUpdate
|
|
from app.core.deps import get_current_user
|
|
from app.models.user import User as UserModel
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/me", response_model=User)
|
|
def get_current_user_info(current_user: UserModel = Depends(get_current_user)):
|
|
return current_user
|
|
|
|
|
|
@router.put("/me", response_model=User)
|
|
def update_current_user(
|
|
user_data: UserUpdate,
|
|
current_user: UserModel = Depends(get_current_user),
|
|
db: Session = Depends(get_db),
|
|
):
|
|
user_service = UserService(db)
|
|
updated_user = user_service.update_user(current_user.id, user_data)
|
|
|
|
if not updated_user:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_404_NOT_FOUND, detail="User not found"
|
|
)
|
|
|
|
return updated_user
|