Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show saved annotations from other users to zeus #5167

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/policies/saved_annotation_policy.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
class SavedAnnotationPolicy < ApplicationPolicy
class Scope < ApplicationPolicy::Scope
def resolve
if user&.zeus?
scope.all
elsif user&.a_course_admin?
if user&.zeus? || user&.a_course_admin?
scope.where(user_id: user.id)
else
scope.none
Expand Down
18 changes: 18 additions & 0 deletions test/controllers/saved_annotation_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,22 @@ def setup

assert_response :success
end

test 'zeus should not have access to saved annotations of other users' do
sign_in users(:staff)
get saved_annotations_url, params: { format: :json }

assert_response :success
assert_equal 1, response.parsed_body.length

sign_in users(:zeus)
get saved_annotations_url, params: { format: :json }

assert_response :success
assert_equal 0, response.parsed_body.length

get saved_annotation_url(@instance), params: { format: :json }

assert_response :forbidden
end
end