6c297b5e81
- Fix email format in AuthService.get_email_in_address to use receipts+{token}@receipts.cartsnitch.com (was broken: @email.cartsnitch.com) - Remove dead EmailInAddressResponse class and GET /auth/me/email-in-address endpoint from auth/routes.py (endpoint moved to routes/user.py) - Add instructions field to EmailInAddressResponse schema - Update routes/user.py to include instructions in the response - Update test URLs from /auth/me/email-in-address to /api/v1/me/email-in-address Co-authored-by: CartSnitch Engineer Bot <cartnoreply@cartsnitch.com> Co-authored-by: Paperclip <noreply@paperclip.ing>
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""User routes: per-user account endpoints (email-in address, etc.)."""
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from cartsnitch_api.auth.dependencies import get_current_user
|
|
from cartsnitch_api.database import get_db
|
|
from cartsnitch_api.schemas import EmailInAddressResponse
|
|
from cartsnitch_api.services.auth import AuthService
|
|
|
|
router = APIRouter(tags=["user"])
|
|
|
|
|
|
@router.get("/me/email-in-address", response_model=EmailInAddressResponse)
|
|
async def get_email_in_address(
|
|
user_id: str = Depends(get_current_user),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
svc = AuthService(db)
|
|
try:
|
|
email_address = await svc.get_email_in_address(user_id)
|
|
return EmailInAddressResponse(
|
|
email_address=email_address,
|
|
instructions=(
|
|
"Forward your digital receipt emails to this address. "
|
|
"We currently support Meijer, Kroger, and Target receipt emails."
|
|
),
|
|
)
|
|
except LookupError:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_404_NOT_FOUND, detail="User not found"
|
|
) from None
|