Skip to content

Commit ad811b0

Browse files
authored
updated auth logic on public plans (#1966)
* updated auth logic on public plans * added skip_authorization statement as 'authorize' is no longer used
1 parent 84e5e8b commit ad811b0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/controllers/plan_exports_controller.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def show
88
@plan = Plan.includes(:answers).find(params[:plan_id])
99

1010
if privately_authorized? && export_params[:form].present?
11+
skip_authorization
1112
@show_coversheet = export_params[:project_details].present?
1213
@show_sections_questions = export_params[:question_headings].present?
1314
@show_unanswered = export_params[:unanswered_questions].present?
@@ -93,7 +94,11 @@ def publicly_authorized?
9394
end
9495

9596
def privately_authorized?
96-
authorize @plan, :export?
97+
if current_user.present?
98+
PlanPolicy.new(current_user, @plan).export?
99+
else
100+
false
101+
end
97102
end
98103

99104
def export_params

0 commit comments

Comments
 (0)