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

Use new permission in schedule controller

Oliver Günther5e5fa5f37e6e
diff --git a/app/controllers/concerns/accounts/authorization.rb b/app/controllers/concerns/accounts/authorization.rb
index a45f130a49d..93320f71eb1 100644
--- a/app/controllers/concerns/accounts/authorization.rb
+++ b/app/controllers/concerns/accounts/authorization.rb
@@ -85,7 +85,7 @@ module Accounts::Authorization
# Action can be:
# * a parameter-like Hash (eg. { controller: '/projects', action: 'edit' })
# * a permission Symbol (eg. :edit_project)
- def do_authorize(action, global: false)
+ def do_authorize(action, global: false) # rubocop:disable Metrics/PerceivedComplexity
is_authorized = if global
User.current.allowed_based_on_permission_context?(action)
else
diff --git a/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rb b/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rb
index 8c8b842494c..d85ad73a1e6 100644
--- a/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings/schedule_controller.rb
@@ -1,9 +1,6 @@
module RecurringMeetings
class ScheduleController < ApplicationController
- before_action do
- do_authorize :create_meetings, global: true
- end
- authorization_checked! :humanize_schedule
+ authorize_with_permission :create_meetings, global: true
around_action :with_user_time_zone
before_action :build_meeting
diff --git a/spec/controllers/concerns/authorization_spec.rb b/spec/controllers/concerns/authorization_spec.rb
index dcf42dde898..60e4aa61807 100644
--- a/spec/controllers/concerns/authorization_spec.rb
+++ b/spec/controllers/concerns/authorization_spec.rb
@@ -115,7 +115,7 @@ RSpec.describe ApplicationController, "enforcement of authorization" do # ruboco
authorize_with_permission :view_project
- def do_authorize(_permission, global: false)
+ def do_authorize(*)
true
end
end
@@ -142,7 +142,7 @@ RSpec.describe ApplicationController, "enforcement of authorization" do # ruboco
render plain: "OK"
end
- def do_authorize(_permission, global: true)
+ def do_authorize(*)
true
end
end
@@ -172,7 +172,7 @@ RSpec.describe ApplicationController, "enforcement of authorization" do # ruboco
load_and_authorize_with_permission_in_optional_project :view_project
- def do_authorize(_permission, global: true)
+ def do_authorize(*)
true
end
end
@@ -209,7 +209,7 @@ RSpec.describe ApplicationController, "enforcement of authorization" do # ruboco
render plain: "OK"
end
- def do_authorize(_permission, global: true)
+ def do_authorize(*)
true
end
end