Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Do not allow public views with a deleted owner to be made private.

Dombi Attiladeb6d6a7f60a
diff --git a/app/contracts/queries/update_contract.rb b/app/contracts/queries/update_contract.rb
index f9b2fafde30..cd00a1e9da0 100644
--- a/app/contracts/queries/update_contract.rb
+++ b/app/contracts/queries/update_contract.rb
@@ -39,6 +39,7 @@ module Queries
# or user saving public queries
if model.public_was
user_allowed_to_change_public
+ user_allowed_to_change_query_to_private unless model.public?
else
user_allowed_to_change_query
user_allowed_to_change_public if model.public?
@@ -68,5 +69,11 @@ module Queries
user.allowed_in_any_project?(:save_queries)
end
end
+
+ def user_allowed_to_change_query_to_private
+ if model.user.is_a? DeletedUser
+ errors.add :base, :error_unauthorized
+ end
+ end
end
end
diff --git a/spec/contracts/queries/update_contract_spec.rb b/spec/contracts/queries/update_contract_spec.rb
index abee0fc27ff..d2c26cc8246 100644
--- a/spec/contracts/queries/update_contract_spec.rb
+++ b/spec/contracts/queries/update_contract_spec.rb
@@ -109,6 +109,12 @@ RSpec.describe Queries::UpdateContract do
end
it_behaves_like "contract is valid"
+
+ context "when the query user is deleted" do
+ let(:user) { DeletedUser.first }
+
+ it_behaves_like "contract user is unauthorized"
+ end
end
end