Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Do some security checks, looking that the objects to edit do belong to the correct workout

Roland Geider2c314ee19c58
diff --git a/manager/views.py b/manager/views.py
index 9ba6bfa32..c2da30951 100644
--- a/manager/views.py
+++ b/manager/views.py
@@ -306,6 +306,10 @@ def edit_day(request, id, day_id=None):
day = get_object_or_404(Day, pk=day_id)
template_data['day'] = day
+ # Check that the day belongs to the workout
+ if day.training.id != workout.id:
+ return HttpResponseForbidden()
+
# Process request
if request.method == 'POST':
day_form = DayForm(request.POST, instance=day)
@@ -372,6 +376,11 @@ def edit_set(request, id, day_id, set_id=None):
workout_set = get_object_or_404(Set, pk=set_id)
template_data['set'] = workout_set
+
+ # Check if all objects belong to the workout
+ if day.training.id != workout.id or workout_set.exerciseday.id != day.id:
+ return HttpResponseForbidden()
+
# Process request
if request.method == 'POST':
set_form = SetForm(request.POST, instance=workout_set)
@@ -470,6 +479,10 @@ def edit_setting(request, id, set_id, exercise_id, setting_id=None):
template_data['exercise'] = exercise
+ # Check that the set belongs to the workout
+ if set_obj.exerciseday.training.id != workout.id:
+ return HttpResponseForbidden()
+
# Load setting
if not setting_id:
setting = Setting()