Skip to content

Commit

Permalink
Bugfix draft page view for user with access only
Browse files Browse the repository at this point in the history
  • Loading branch information
Brice Sanchez committed Nov 14, 2016
1 parent 87535ab commit 511fcfb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pages/app/controllers/refinery/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class PagesController < ::ApplicationController
include Pages::RenderOptions

before_action :find_page, :set_canonical
before_action :error_404, :unless => :current_user_can_view_page?
before_action :error_404, unless: :current_user_can_view_page?

# Save whole Page after delivery
after_action :write_cache?
Expand Down Expand Up @@ -60,9 +60,13 @@ def should_redirect_to_friendly_url?
end

def current_user_can_view_page?
page.live? || authorisation_manager.allow?(:plugin, "refinery_pages")
page.live? || current_refinery_user_can_access?("refinery_pages")
end

def current_refinery_user_can_access?(plugin)
admin? && authorisation_manager.allow?(:plugin, plugin)
end

def first_live_child
page.children.order('lft ASC').live.first
end
Expand Down

0 comments on commit 511fcfb

Please sign in to comment.