Skip to content

Commit

Permalink
Merge pull request #4902 from dodona-edu/fix/403-saved-annotations
Browse files Browse the repository at this point in the history
Avoid 403 errors when a user cannot access linked saved annotations
  • Loading branch information
jorg-vr authored Aug 17, 2023
2 parents cd97690 + 239d015 commit 1be48ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/views/annotations/_annotation.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
json.extract! annotation, :id, :line_nr, :annotation_text, :user_id, :submission_id, :saved_annotation_id, :created_at, :updated_at, :course_id, :column, :rows, :columns
json.extract! annotation, :id, :line_nr, :annotation_text, :user_id, :submission_id, :created_at, :updated_at, :course_id, :column, :rows, :columns
json.row annotation.line_nr || 0
if annotation.is_a?(Question)
json.extract! annotation, :question_state
Expand Down Expand Up @@ -41,3 +41,6 @@ json.responses annotation.responses do |response|
json.partial! response, as: :annotation
end
json.thread_root_id annotation.thread_root_id

# Only include the saved annotation id if the user is allowed to see it
json.saved_annotation_id annotation.saved_annotation_id if annotation.saved_annotation.present? && SavedAnnotationPolicy.new(current_user, annotation.saved_annotation).show?

0 comments on commit 1be48ad

Please sign in to comment.