fix(loyalty): replace broad exception handlers with specific types and rename onboarding service
- Replace `except Exception` with specific exception types in google_wallet_service.py (requests.RequestException, ValueError, etc.) and apple_wallet_service.py (httpx.HTTPError, OSError, ssl.SSLError) - Rename loyalty_onboarding.py -> loyalty_onboarding_service.py to match NAM-002 naming convention (+ test file + imports) - Add PasswordChangeResponse Pydantic model to user_account API, removing raw dict return and noqa suppression Resolves 12 EXC-003 + 1 NAM-002 architecture warnings in loyalty module. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ from sqlalchemy.orm import Session
|
||||
from app.core.database import get_db
|
||||
from app.modules.tenancy.schemas.auth import UserContext
|
||||
from app.modules.tenancy.schemas.user_account import (
|
||||
PasswordChangeResponse,
|
||||
UserAccountResponse,
|
||||
UserAccountUpdate,
|
||||
UserPasswordChange,
|
||||
@@ -49,7 +50,7 @@ def create_account_router(auth_dependency: Callable) -> APIRouter:
|
||||
db.commit()
|
||||
return result
|
||||
|
||||
@router.put("/password")
|
||||
@router.put("/password", response_model=PasswordChangeResponse)
|
||||
async def change_my_password(
|
||||
password_data: UserPasswordChange,
|
||||
current_user: UserContext = Depends(auth_dependency),
|
||||
@@ -60,7 +61,7 @@ def create_account_router(auth_dependency: Callable) -> APIRouter:
|
||||
db, current_user.id, password_data.model_dump()
|
||||
)
|
||||
db.commit()
|
||||
return {"message": "Password changed successfully"} # noqa: API001
|
||||
return PasswordChangeResponse(message="Password changed successfully")
|
||||
|
||||
return router
|
||||
|
||||
|
||||
Reference in New Issue
Block a user