Skip to content

Commit 391a218

Browse files
committed
check authorizaiton, feature flag and access
1 parent 3510789 commit 391a218

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Diff for: app/controllers/project_phases/hover_card_controller.rb

+15-1
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,30 @@
3030

3131
module ProjectPhases
3232
class HoverCardController < ApplicationController
33-
no_authorization_required! :show
33+
before_action :authorize
34+
before_action :check_feature_flag
3435
before_action :assign_gate
3536
before_action :find_phase
37+
before_action :check_access
3638

3739
layout false
3840

3941
def show; end
4042

4143
private
4244

45+
def check_feature_flag
46+
return if OpenProject::FeatureDecisions.stages_and_gates_active?
47+
48+
render json: { error: "Not found" }, status: :not_found
49+
end
50+
51+
def check_access
52+
return if User.current.allowed_in_project?(:view_project_phases, @phase.project)
53+
54+
render json: { error: "Forbidden" }, status: :forbidden
55+
end
56+
4357
def assign_gate
4458
@gate = params[:gate]
4559
return if @gate.in?(%w[start finish])

Diff for: config/initializers/permissions.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@
135135
require: :member
136136

137137
map.permission :view_project_phases,
138-
{},
138+
{
139+
"project_phases/hover_card": :show
140+
},
139141
permissible_on: :project,
140142
dependencies: :view_project,
141143
visible: -> { OpenProject::FeatureDecisions.stages_and_gates_active? }

0 commit comments

Comments
 (0)