Skip to content

Commit bf05372

Browse files
authored
Merge branch 'master' into development
2 parents 4eef78d + 0c719e8 commit bf05372

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

app/controllers/public_pages_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def template_export
3030
@template = Template.live(params[:id])
3131
# covers authorization for this action.
3232
# Pundit dosent support passing objects into scoped policies
33-
unless PublicPagePolicy.new(@template).template_export?
33+
unless PublicPagePolicy.new(current_user, @template).template_export?
3434
msg = 'You are not authorized to export that template'
3535
redirect_to public_templates_path, notice: msg and return
3636
# raise Pundit::NotAuthorizedError

app/policies/public_page_policy.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
# Security rules for the public pages
44
# Note the method names here correspond with controller actions
55
class PublicPagePolicy < ApplicationPolicy
6-
# NOTE: @user is the signed_in_user and @record is an instance of Plan
6+
# rubocop:disable Lint/MissingSuper
7+
def initialize(user, record = nil)
8+
@user = user
9+
@record = record
10+
end
11+
# rubocop:enable Lint/MissingSuper
712

813
def plan_index?
914
true
@@ -14,7 +19,7 @@ def template_index?
1419
end
1520

1621
def template_export?
17-
@record.present? && @record.published?
22+
@user.present? && @record.published?
1823
end
1924

2025
def plan_export?

0 commit comments

Comments
 (0)