mirror of
https://github.com/StefBuwalda/cal_counter.git
synced 2025-10-30 11:19:59 +00:00
Restrict food deletion to item owner
Added a check to ensure only the owner of a FoodItem can delete it. This improves security by preventing unauthorized deletions.
This commit is contained in:
@@ -32,7 +32,7 @@ def barcode_test():
|
|||||||
def delete_food(id):
|
def delete_food(id):
|
||||||
item = FoodItem.query.get(id)
|
item = FoodItem.query.get(id)
|
||||||
if item:
|
if item:
|
||||||
# if item.owner_id == current_user.id:
|
if item.owner_id == current_user.id:
|
||||||
db.session.delete(item)
|
db.session.delete(item)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return redirect(url_for("admin.food_items"))
|
return redirect(url_for("admin.food_items"))
|
||||||
|
|||||||
Reference in New Issue
Block a user