Prevent cross access of PG for different exercise

Here, we are only checking the condition based on the URL if both parameters (exercise and programming group) are given. Otherwise, we skip the check.
This commit is contained in:
Sebastian Serth
2023-11-23 01:11:00 +01:00
committed by Sebastian Serth
parent 3048cf2644
commit 1e06ab3fa9

View File

@ -94,6 +94,8 @@ class ProgrammingGroupsController < ApplicationController
private private
def authorize! def authorize!
raise Pundit::NotAuthorizedError if @programming_group.present? && @exercise.present? && @programming_group.exercise != @exercise
authorize(@programming_group || @programming_groups) authorize(@programming_group || @programming_groups)
end end