app/controllers/application_controller.rb
# Make sure the user is allowed to see a specific page
# includes a special case for restricted works and series, since we want to encourage people to sign up to read them
Make sure the user is allowed to see a specific page
includes a special case for restricted works and series, since we want to encourage people to sign up to read them
Make sure the user is allowed to see a specific page includes a special case for restricted works and series since we want to encourage people to sign up to read them
def check_visibility
    if @check_visibility_of.respond_to?(:restricted) && @check_visibility_of.restricted && User.current_user.nil?
      redirect_to login_path(:restricted => true)
    elsif @check_visibility_of.is_a? Skin
      access_denied unless logged_in_as_admin? || current_user_owns?(@check_visibility_of) || @check_visibility_of.official?
    else
      is_hidden = (@check_visibility_of.respond_to?(:visible) && !@check_visibility_of.visible) ||
                  (@check_visibility_of.respond_to?(:visible?) && !@check_visibility_of.visible?) ||
                  (@check_visibility_of.respond_to?(:hidden_by_admin?) && @check_visibility_of.hidden_by_admin?)
      can_view_hidden = logged_in_as_admin? || current_user_owns?(@check_visibility_of)
      access_denied if (is_hidden && !can_view_hidden)
    end
  end
def check_visibility if @check_visibility_of . respond_to? ( :restricted ) && @check_visibility_of . restricted && User . current_user . nil? redirect_to login_path ( :restricted => true ) elsif @check_visibility_of . is_a? Skin access_denied unless logged_in_as_admin? || current_user_owns? ( @check_visibility_of ) || @check_visibility_of . official? else is_hidden = ( @check_visibility_of . respond_to? ( :visible ) && ! @check_visibility_of . visible ) || ( @check_visibility_of . respond_to? ( :visible? ) && ! @check_visibility_of . visible? ) || ( @check_visibility_of . respond_to? ( :hidden_by_admin? ) && @check_visibility_of . hidden_by_admin? ) can_view_hidden = logged_in_as_admin? || current_user_owns? ( @check_visibility_of ) access_denied if ( is_hidden && ! can_view_hidden ) end end
Make sure the user is allowed to see a specific page
includes a special case for restricted works and series, since we want to encourage people to sign up to read them
Make sure the user is allowed to see a specific page includes a special case for restricted works and series since we want to encourage people to sign up to read them