tueniuu commited on
Commit
52e6150
·
verified ·
1 Parent(s): 11f8d5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -3
app.py CHANGED
@@ -84,7 +84,7 @@ async def get_itinerary_data(authorization: str = Header(...)):
84
  raise HTTPException(status_code=500, detail="Internal server error")
85
 
86
  @app.delete("/itinerary/{itinerary_id}")
87
- async def delete_itinerary(itinerary_id: int, authorization: str = Header(...)):
88
  """
89
  Deletes a specific itinerary, ensuring the user owns it.
90
  """
@@ -103,13 +103,11 @@ async def delete_itinerary(itinerary_id: int, authorization: str = Header(...)):
103
  raise HTTPException(status_code=401, detail="User ID not found in token payload")
104
 
105
  # Securely delete the itinerary by matching both its ID and the user's ID
106
- # This prevents a user from deleting someone else's itinerary
107
  response = supabase.table("itineraries").delete().match({
108
  "id": itinerary_id,
109
  "user_id": user_id
110
  }).execute()
111
 
112
- # Check if the delete operation affected any rows
113
  if not response.data:
114
  raise HTTPException(status_code=404, detail="Itinerary not found or you do not have permission to delete it.")
115
 
 
84
  raise HTTPException(status_code=500, detail="Internal server error")
85
 
86
  @app.delete("/itinerary/{itinerary_id}")
87
+ async def delete_itinerary(itinerary_id: str, authorization: str = Header(...)): # 🎯 MODIFIED: Changed int to str
88
  """
89
  Deletes a specific itinerary, ensuring the user owns it.
90
  """
 
103
  raise HTTPException(status_code=401, detail="User ID not found in token payload")
104
 
105
  # Securely delete the itinerary by matching both its ID and the user's ID
 
106
  response = supabase.table("itineraries").delete().match({
107
  "id": itinerary_id,
108
  "user_id": user_id
109
  }).execute()
110
 
 
111
  if not response.data:
112
  raise HTTPException(status_code=404, detail="Itinerary not found or you do not have permission to delete it.")
113