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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
fix authorization checks with decorated work packages
ulferts6da98f121b9d
diff --git a/app/services/authorization.rb b/app/services/authorization.rbindex 20b48fbf2df..bea3be8a338 100644--- a/app/services/authorization.rb+++ b/app/services/authorization.rb@@ -46,6 +46,13 @@ module Authorization# Returns all roles a user has in a certain project, for a specific entity or globallydef roles(user, context = nil)+ # Sometimes, and the conditions are unclear, the context is a decorated object.+ # Most of the times, this would then be a 'WorkPackageEagerLoadingWrapper' instance.+ # If that is the case, the following code would trip up:+ # * Member.can_be_member_of would wrongfully state that the context does not fit+ # * Authorization::UserEntityRolesQuery.query would use the decorator's class name for the sql.+ context = context.__getobj__ if context.is_a?(SimpleDelegator)+if context.is_a?(Project)Authorization::UserProjectRolesQuery.query(user, context)elsif Member.can_be_member_of?(context)