From 297789a34863139392acecc7319550ad299af30d Mon Sep 17 00:00:00 2001 From: Marcin Ciunelis Date: Mon, 3 Aug 2015 23:41:14 +0200 Subject: [PATCH 01/16] update compass-rails --- Gemfile.lock | 61 +++++++++++++++++++++++++++------------------- browsercms.gemspec | 2 +- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7edd38f7f..60cdb73aa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,7 @@ PATH ancestry (~> 2.0.0) bootstrap-sass ckeditor_rails (~> 4.3.0) - compass-rails (~> 1.1.3) + compass-rails (~> 2.0.1) devise (~> 3.0) jquery-rails (~> 3.1) jquery-ui-rails (~> 4.1) @@ -57,10 +57,14 @@ GEM childprocess (>= 0.3.6) cucumber (>= 1.1.1) rspec-expectations (>= 2.7.0) - bcrypt (3.1.7) + autoprefixer-rails (5.2.1.1) + execjs + json + bcrypt (3.1.10) bluecloth (2.2.0) - bootstrap-sass (3.2.0.2) - sass (~> 3.2) + bootstrap-sass (3.3.5.1) + autoprefixer-rails (>= 5.0.0.1) + sass (>= 3.3.0) builder (3.1.4) capybara (2.1.0) mime-types (>= 1.16) @@ -70,28 +74,29 @@ GEM xpath (~> 2.0) childprocess (0.3.9) ffi (~> 1.0, >= 1.0.11) - chunky_png (1.3.1) + chunky_png (1.3.4) ckeditor_rails (4.3.4) railties (>= 3.0) climate_control (0.0.3) activesupport (>= 3.0) - cocaine (0.5.4) + cocaine (0.5.7) climate_control (>= 0.0.3, < 1.0) - compass (1.0.1) + compass (1.0.3) chunky_png (~> 1.2) - compass-core (~> 1.0.1) + compass-core (~> 1.0.2) compass-import-once (~> 1.0.5) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) sass (>= 3.3.13, < 3.5) - compass-core (1.0.1) + compass-core (1.0.3) multi_json (~> 1.0) sass (>= 3.3.0, < 3.5) compass-import-once (1.0.5) sass (>= 3.2, < 3.5) - compass-rails (1.1.7) - compass (>= 0.12.2) - sprockets (<= 2.11.0) + compass-rails (2.0.4) + compass (~> 1.0.0) + sass-rails (<= 5.0.1) + sprockets (< 2.13) cucumber (1.3.6) builder (>= 2.1.2) diff-lcs (>= 1.1.3) @@ -104,10 +109,11 @@ GEM nokogiri (>= 1.5.0) daemons (1.1.9) database_cleaner (1.2.0) - devise (3.3.0) + devise (3.5.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 3.2.6, < 5) + responders thread_safe (~> 0.1) warden (~> 1.2.3) diff-lcs (1.2.4) @@ -122,18 +128,19 @@ GEM railties (>= 3.0.0) faye-websocket (0.4.7) eventmachine (>= 0.12.0) - ffi (1.9.0) + ffi (1.9.10) gherkin (2.12.1) multi_json (~> 1.3) hashie (2.0.5) hike (1.2.3) http_parser.rb (0.5.3) i18n (0.6.11) - jquery-rails (3.1.2) + jquery-rails (3.1.3) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) jquery-ui-rails (4.2.1) railties (>= 3.2.16) + json (1.8.3) launchy (2.3.0) addressable (~> 2.3) m (1.3.2) @@ -180,7 +187,7 @@ GEM hashie (>= 1.1.0) quiet_assets (1.0.2) railties (>= 3.1, < 5.0) - rack (1.5.2) + rack (1.5.5) rack-test (0.6.2) rack (>= 1.0) rails (4.0.2) @@ -197,23 +204,27 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.1.1) - rb-fsevent (0.9.4) + rb-fsevent (0.9.5) rb-inotify (0.9.5) ffi (>= 0.5.0) + responders (1.1.2) + railties (>= 3.2, < 4.2) rspec-expectations (2.14.1) diff-lcs (>= 1.1.3, < 2.0) ruby-prof (0.13.0) - sass (3.4.5) - sass-rails (4.0.1) + sass (3.4.16) + sass-rails (5.0.1) railties (>= 4.0.0, < 5.0) - sass (>= 3.1.10) - sprockets-rails (~> 2.0.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (~> 1.1) simple_form (3.1.0.rc2) actionpack (~> 4.0) activemodel (~> 4.0) single_test (0.6.0) rake - sprockets (2.10.1) + sprockets (2.12.4) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) @@ -225,7 +236,7 @@ GEM sqlite3 (1.3.7) sqlite3-ruby (1.3.3) sqlite3 (>= 1.3.3) - term-ansicolor (1.3.0) + term-ansicolor (1.3.2) tins (~> 1.0) thin (1.5.1) daemons (>= 1.0.9) @@ -234,7 +245,7 @@ GEM thor (0.18.1) thread_safe (0.3.4) tilt (1.4.1) - tins (1.3.3) + tins (1.5.4) treetop (1.4.15) polyglot polyglot (>= 0.3.1) @@ -242,7 +253,7 @@ GEM uglifier (2.1.2) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) - underscore-rails (1.7.0) + underscore-rails (1.8.3) warden (1.2.3) rack (>= 1.0) will_paginate (3.0.7) diff --git a/browsercms.gemspec b/browsercms.gemspec index 2c0d6dc06..d91da1baf 100644 --- a/browsercms.gemspec +++ b/browsercms.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |s| s.add_dependency("devise", "~> 3.0") s.add_dependency("sass-rails") s.add_dependency("bootstrap-sass") - s.add_dependency("compass-rails", "~> 1.1.3") + s.add_dependency("compass-rails", "~> 2.0.1") s.add_dependency("ancestry", "~> 2.0.0") s.add_dependency("ckeditor_rails", "~> 4.3.0") s.add_dependency("underscore-rails", "~> 1.4") From a07e0a888b9c69739a1ede61d23d86ce8c087ea0 Mon Sep 17 00:00:00 2001 From: Marcin Ciunelis Date: Mon, 3 Aug 2015 23:47:48 +0200 Subject: [PATCH 02/16] update compass-rails --- Gemfile.lock | 14 +++++++------- browsercms.gemspec | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 60cdb73aa..7bb9f9ac4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,7 @@ PATH ancestry (~> 2.0.0) bootstrap-sass ckeditor_rails (~> 4.3.0) - compass-rails (~> 2.0.1) + compass-rails (~> 2.0.4) devise (~> 3.0) jquery-rails (~> 3.1) jquery-ui-rails (~> 4.1) @@ -134,7 +134,7 @@ GEM hashie (2.0.5) hike (1.2.3) http_parser.rb (0.5.3) - i18n (0.6.11) + i18n (0.7.0) jquery-rails (3.1.3) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) @@ -188,7 +188,7 @@ GEM quiet_assets (1.0.2) railties (>= 3.1, < 5.0) rack (1.5.5) - rack-test (0.6.2) + rack-test (0.6.3) rack (>= 1.0) rails (4.0.2) actionmailer (= 4.0.2) @@ -203,7 +203,7 @@ GEM activesupport (= 4.0.2) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.1.1) + rake (10.4.2) rb-fsevent (0.9.5) rb-inotify (0.9.5) ffi (>= 0.5.0) @@ -242,14 +242,14 @@ GEM daemons (>= 1.0.9) eventmachine (>= 0.12.6) rack (>= 1.0.0) - thor (0.18.1) - thread_safe (0.3.4) + thor (0.19.1) + thread_safe (0.3.5) tilt (1.4.1) tins (1.5.4) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.41) + tzinfo (0.3.44) uglifier (2.1.2) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) diff --git a/browsercms.gemspec b/browsercms.gemspec index d91da1baf..f39a56149 100644 --- a/browsercms.gemspec +++ b/browsercms.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |s| s.add_dependency("devise", "~> 3.0") s.add_dependency("sass-rails") s.add_dependency("bootstrap-sass") - s.add_dependency("compass-rails", "~> 2.0.1") + s.add_dependency("compass-rails", "~> 2.0.4") s.add_dependency("ancestry", "~> 2.0.0") s.add_dependency("ckeditor_rails", "~> 4.3.0") s.add_dependency("underscore-rails", "~> 1.4") From b57010fae0db3984b4b64d45d7d78fb1bcfa9d5f Mon Sep 17 00:00:00 2001 From: Marcin Ciunelis Date: Thu, 6 Aug 2015 19:37:30 +0200 Subject: [PATCH 03/16] add route_name --- config/routes.rb | 3 ++- lib/cms/route_extensions.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index ca9710056..790f8c371 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,7 +15,8 @@ path: :users, class_name: 'Cms::PersistentUser', controllers: {passwords: 'cms/passwords'}, - module: :devise + module: :devise, + router_name: :cms devise_scope :cms_user do get '/login' => "sessions#new", :as => 'login' diff --git a/lib/cms/route_extensions.rb b/lib/cms/route_extensions.rb index a913815a2..3453989fd 100644 --- a/lib/cms/route_extensions.rb +++ b/lib/cms/route_extensions.rb @@ -44,7 +44,8 @@ def mount_browsercms path: '', skip: :password, path_names: {sign_in: 'login'}, - controllers: {sessions: 'cms/sites/sessions'} + controllers: {sessions: 'cms/sites/sessions'}, + router_name: :cms devise_scope :cms_user do get '/forgot-password' => "cms/sites/passwords#new", :as => 'forgot_password' From 1c8bf2c1cf417e88835b8097ffb1ad71e052ca83 Mon Sep 17 00:00:00 2001 From: Marcin Ciunelis Date: Thu, 6 Aug 2015 19:37:49 +0200 Subject: [PATCH 04/16] rename current_user to current_cms_user --- lib/cms/authentication/controller.rb | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/cms/authentication/controller.rb b/lib/cms/authentication/controller.rb index 0b7749cc3..f07a51c8b 100644 --- a/lib/cms/authentication/controller.rb +++ b/lib/cms/authentication/controller.rb @@ -23,7 +23,7 @@ module Controller # Inclusion hook to make #current_user and #logged_in? # available as ActionView helper methods. def self.included(base) - base.send :helper_method, :current_user, :logged_in? if base.respond_to? :helper_method + base.send :helper_method, :logged_in? if base.respond_to? :helper_method base.extend ClassMethods end @@ -52,16 +52,25 @@ def check_permissions(*perms) # Returns true or false if the user is logged in. # Preloads Cms::User.current with the user model if they're logged in. def logged_in? - !current_user.nil? && !current_user.guest? + !current_cms_user.nil? && !current_cms_user.guest? end # Returns the current user if logged in. If no user is logged in, returns the 'Guest' user which represents a # what a visitor can do without being logged in. - def current_user - @current_user ||= begin - Cms::PersistentUser.current = current_cms_user || Cms::User.guest - end + # def current_cms_user + # @current_cms_user ||= begin + # Cms::PersistentUser.current = current_cms_user || Cms::User.guest + # end + # end + + def current_cms_user + + end + + def current_cms_user_with_guest + @current_cms_user ||= Cms::PersistentUser.current = current_cms_user_without_guest || Cms::User.guest end + alias_method_chain :current_cms_user, :guest # Redirect as appropriate when an access request fails. # From f40c55cc944baa7122f26cad77de08db13e5f707 Mon Sep 17 00:00:00 2001 From: Marcin Ciunelis Date: Fri, 14 Aug 2015 15:33:24 +0200 Subject: [PATCH 05/16] rename current_user to current_cms_user --- app/controllers/cms/content_block_controller.rb | 8 ++++---- app/controllers/cms/content_controller.rb | 10 +++++----- app/controllers/cms/dashboard_controller.rb | 4 ++-- app/controllers/cms/links_controller.rb | 4 ++-- app/controllers/cms/pages_controller.rb | 8 ++++---- app/controllers/cms/section_nodes_controller.rb | 2 +- app/controllers/cms/sections_controller.rb | 8 ++++---- app/controllers/cms/tasks_controller.rb | 8 ++++---- app/controllers/cms/user_controller.rb | 2 +- app/controllers/cms/users_controller.rb | 4 ++-- app/helpers/cms/content_block_helper.rb | 12 ++++++------ app/helpers/cms/page_helper.rb | 2 +- app/helpers/cms/path_helper.rb | 2 +- app/helpers/cms/rendering_helper.rb | 2 +- app/helpers/cms/ui_elements_helper.rb | 6 +++--- app/models/cms/portlet.rb | 2 +- .../render_block_in_main_container.html.erb | 2 +- app/views/cms/pages/_form.html.erb | 2 +- app/views/layouts/cms/_main_menu.html.erb | 12 ++++++------ app/views/layouts/cms/page_editor.html.erb | 6 +++--- features/step_definitions/user_steps.rb | 4 ++-- features/support/cms_api.rb | 2 +- lib/cms/attachments/attachment_serving.rb | 2 +- lib/cms/authentication/controller.rb | 15 ++------------- lib/cms/content_rendering_support.rb | 4 ++-- lib/cms/controllers/admin_controller.rb | 6 +++--- lib/cms/mobile_aware.rb | 2 +- test/dummy/app/views/devise_tests/show.html.erb | 2 +- .../cms/content_block_controller_test.rb | 2 +- test/unit/behaviors/attaching_test.rb | 2 +- test/unit/lib/acts_as_content_page_test.rb | 2 +- 31 files changed, 69 insertions(+), 80 deletions(-) diff --git a/app/controllers/cms/content_block_controller.rb b/app/controllers/cms/content_block_controller.rb index e88dfa168..277e34115 100644 --- a/app/controllers/cms/content_block_controller.rb +++ b/app/controllers/cms/content_block_controller.rb @@ -319,9 +319,9 @@ def check_permissions when "index", "show", "new", "create", "version", "versions" # Allow when "edit", "update", "inline" - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@block) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@block) when "destroy", "publish", "revert_to" - raise Cms::Errors::AccessDenied unless current_user.able_to_publish?(@block) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_publish?(@block) else raise Cms::Errors::AccessDenied end @@ -330,7 +330,7 @@ def check_permissions private def render_block_in_main_container - ensure_current_user_can_view(@block) + ensure_current_cms_user_can_view(@block) show_content_as_page(@block) render 'render_block_in_main_container', layout: @block.class.layout end @@ -341,7 +341,7 @@ def render_block_in_content_library def render_editing_frame_or_block_in_main_container if @block.class.addressable? - if current_user.able_to_edit?(@block) + if current_cms_user.able_to_edit?(@block) render_toolbar_and_iframe else render_block_in_main_container diff --git a/app/controllers/cms/content_controller.rb b/app/controllers/cms/content_controller.rb index 58bed6dcb..cc32f1e04 100644 --- a/app/controllers/cms/content_controller.rb +++ b/app/controllers/cms/content_controller.rb @@ -47,7 +47,7 @@ def edit def preview @mode = "view" @page = Page.find_draft(params[:id].to_i) - ensure_current_user_can_view(@page) + ensure_current_cms_user_can_view(@page) render_page end @@ -114,7 +114,7 @@ def redirect_non_cms_users_to_public_site logger.debug "Using cms subdomain is enabled" if request_is_for_cms_subdomain? logger.debug "User has required a page on the cms subdomain." - if current_user.able_to?(:edit_content, :publish_content, :administrate) + if current_cms_user.able_to?(:edit_content, :publish_content, :administrate) logger.debug "User has access to cms" @show_toolbar = true else @@ -126,7 +126,7 @@ def redirect_non_cms_users_to_public_site end else logger.debug "Using cms subdomain is disabled" - if current_user.able_to?(:edit_content, :publish_content, :administrate) + if current_cms_user.able_to?(:edit_content, :publish_content, :administrate) @show_toolbar = true end end @@ -157,7 +157,7 @@ def try_to_stream_file end def load_page - if current_user.able_to?(:edit_content, :publish_content, :administrate) + if current_cms_user.able_to?(:edit_content, :publish_content, :administrate) logger.debug "Displaying draft version of page" @page = Page.find_draft(@path) else @@ -167,7 +167,7 @@ def load_page end def check_access_to_page - ensure_current_user_can_view(@page) + ensure_current_cms_user_can_view(@page) end end end diff --git a/app/controllers/cms/dashboard_controller.rb b/app/controllers/cms/dashboard_controller.rb index e58912840..9e105d241 100644 --- a/app/controllers/cms/dashboard_controller.rb +++ b/app/controllers/cms/dashboard_controller.rb @@ -3,8 +3,8 @@ class DashboardController < Cms::BaseController def index @unpublished_pages = Page.unpublished.order("updated_at desc") - @unpublished_pages = @unpublished_pages.select { |page| current_user.able_to_publish?(page) } - @incomplete_tasks = current_user.tasks.incomplete. + @unpublished_pages = @unpublished_pages.select { |page| current_cms_user.able_to_publish?(page) } + @incomplete_tasks = current_cms_user.tasks.incomplete. includes(:page). order("#{Task.table_name}.due_date desc, #{Page.table_name}.name"). references(:page) diff --git a/app/controllers/cms/links_controller.rb b/app/controllers/cms/links_controller.rb index ea668b59b..8d5099507 100644 --- a/app/controllers/cms/links_controller.rb +++ b/app/controllers/cms/links_controller.rb @@ -64,12 +64,12 @@ def link_params def load_section @section = Section.find(params[:section_id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@section) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@section) end def load_link @link = Link.find(params[:id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@link) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@link) end def load_draft_link diff --git a/app/controllers/cms/pages_controller.rb b/app/controllers/cms/pages_controller.rb index 375435096..6cffad6e4 100644 --- a/app/controllers/cms/pages_controller.rb +++ b/app/controllers/cms/pages_controller.rb @@ -73,7 +73,7 @@ def destroy define_method status do if params[:page_ids] @pages = params[:page_ids].map { |id| Page.find(id) } - raise Cms::Errors::AccessDenied unless @pages.all? { |page| current_user.able_to_edit?(page) } + raise Cms::Errors::AccessDenied unless @pages.all? { |page| current_cms_user.able_to_edit?(page) } @pages.each { |page| page.send(status) } flash[:notice] = "#{params[:page_ids].size} pages #{verb}" redirect_to dashboard_url @@ -117,7 +117,7 @@ def page_params end def strip_visibility_params - unless current_user.able_to?(:publish_content) + unless current_cms_user.able_to?(:publish_content) params[:page].delete :hidden params[:page].delete :archived params[:page].delete :visibility @@ -126,7 +126,7 @@ def strip_visibility_params def load_page @page = Page.find(params[:id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@page) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@page) end def load_draft_page @@ -136,7 +136,7 @@ def load_draft_page def load_section @section = Section.find(params[:section_id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@section) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@section) end def hide_toolbar diff --git a/app/controllers/cms/section_nodes_controller.rb b/app/controllers/cms/section_nodes_controller.rb index d8135c3bb..e469b8d0a 100644 --- a/app/controllers/cms/section_nodes_controller.rb +++ b/app/controllers/cms/section_nodes_controller.rb @@ -4,7 +4,7 @@ class SectionNodesController < Cms::BaseController check_permissions :publish_content, :except => [:index] def index - @modifiable_sections = current_user.modifiable_sections + @modifiable_sections = current_cms_user.modifiable_sections @public_sections = Group.guest.sections.to_a # Load once here so that every section doesn't need to. @sitemap = Section.sitemap diff --git a/app/controllers/cms/sections_controller.rb b/app/controllers/cms/sections_controller.rb index c47d360ba..a743d7242 100644 --- a/app/controllers/cms/sections_controller.rb +++ b/app/controllers/cms/sections_controller.rb @@ -27,7 +27,7 @@ def new def create @section = Cms::Section.new(section_params) @section.parent = @parent - @section.groups = @section.parent.groups unless current_user.able_to?(:administrate) + @section.groups = @section.parent.groups unless current_cms_user.able_to?(:administrate) if @section.save flash[:notice] = "Section '#{@section.name}' was created" redirect_to @section @@ -40,7 +40,7 @@ def edit end def update - params[:section].delete('group_ids') if params[:section] && !current_user.able_to?(:administrate) + params[:section].delete('group_ids') if params[:section] && !current_cms_user.able_to?(:administrate) @section.attributes = section_params() if @section.save flash[:notice] = "Section '#{@section.name}' was updated" @@ -80,12 +80,12 @@ def section_params def load_parent @parent = Cms::Section.find(params[:section_id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@parent) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@parent) end def load_section @section = Cms::Section.find(params[:id]) - raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@section) + raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@section) end def public_groups diff --git a/app/controllers/cms/tasks_controller.rb b/app/controllers/cms/tasks_controller.rb index ae41a922f..c593a195f 100644 --- a/app/controllers/cms/tasks_controller.rb +++ b/app/controllers/cms/tasks_controller.rb @@ -4,12 +4,12 @@ class TasksController < Cms::BaseController before_filter :load_page, :only => [:new, :create] def new - @task = @page.tasks.build(:assigned_by => current_user) + @task = @page.tasks.build(:assigned_by => current_cms_user) end def create @task = @page.tasks.build(task_params()) - @task.assigned_by = current_user + @task.assigned_by = current_cms_user if @task.save flash[:notice] = "Page was assigned to '#{@task.assigned_to.login}'" redirect_to @page.path @@ -21,7 +21,7 @@ def create def complete if params[:task_ids] Task.where(["id in (?)", params[:task_ids]]).each do |t| - if t.assigned_to == current_user + if t.assigned_to == current_cms_user t.mark_as_complete! end end @@ -29,7 +29,7 @@ def complete redirect_to dashboard_path else @task = Task.find(params[:id]) - if @task.assigned_to == current_user + if @task.assigned_to == current_cms_user if @task.mark_as_complete! flash[:notice] = "Task was marked as complete" end diff --git a/app/controllers/cms/user_controller.rb b/app/controllers/cms/user_controller.rb index aa8f85f8a..4754470b9 100644 --- a/app/controllers/cms/user_controller.rb +++ b/app/controllers/cms/user_controller.rb @@ -2,7 +2,7 @@ module Cms class UserController < Cms::ApplicationController # Return information about the current user as json. Can be used by cached html pages do create interactive elements. def show - render json: Cms::UserPresenter.new(current_user) + render json: Cms::UserPresenter.new(current_cms_user) end end end diff --git a/app/controllers/cms/users_controller.rb b/app/controllers/cms/users_controller.rb index 80adee0f3..860906362 100644 --- a/app/controllers/cms/users_controller.rb +++ b/app/controllers/cms/users_controller.rb @@ -56,7 +56,7 @@ def change_password def update_password if user.update(cms_user_params) flash[:notice] = "Password for '#{user.login}' was changed" - redirect_to(current_user.able_to?(:administrate) ? users_path : "/") + redirect_to(current_cms_user.able_to?(:administrate) ? users_path : "/") else render :action => 'change_password' end @@ -119,7 +119,7 @@ def set_menu_section end def only_self_or_administrator - raise Cms::Errors::AccessDenied if !current_user.able_to?(:administrate) && params[:id].to_i != current_user.id + raise Cms::Errors::AccessDenied if !current_cms_user.able_to?(:administrate) && params[:id].to_i != current_cms_user.id end end end \ No newline at end of file diff --git a/app/helpers/cms/content_block_helper.rb b/app/helpers/cms/content_block_helper.rb index 84c0c26e5..c08b9dfcb 100644 --- a/app/helpers/cms/content_block_helper.rb +++ b/app/helpers/cms/content_block_helper.rb @@ -10,15 +10,15 @@ module ContentBlockHelper # * If the user can edit/publish it def block_row_tag(block) cname = class_name_for(block) - can_modify = current_user.able_to_modify?(block) + can_modify = current_cms_user.able_to_modify?(block) options = { :id => "#{cname}_#{block.id}", :class => cname } options[:class] += block.class.publishable? && !block.published? ? ' draft' : ' published' - options[:class] += ' non-editable' unless can_modify && current_user.able_to?(:edit_content) - options[:class] += ' non-publishable' unless can_modify && current_user.able_to?(:publish_content) + options[:class] += ' non-editable' unless can_modify && current_cms_user.able_to?(:edit_content) + options[:class] += ' non-publishable' unless can_modify && current_cms_user.able_to?(:publish_content) tag "tr", options, true end @@ -28,7 +28,7 @@ def block_row_tag(block) # We use 'data-' elements here to avoid duplication of path calculations. def content_block_tr_tag(block) cname = class_name_for(block) - can_modify = current_user.able_to_modify?(block) + can_modify = current_cms_user.able_to_modify?(block) options = {} data = options[:data] = {} @@ -36,8 +36,8 @@ def content_block_tr_tag(block) options[:id] = "#{cname}_#{block.id}" options[:class] = [cname] - options[:class] << 'non-editable' unless can_modify && current_user.able_to?(:edit_content) - options[:class] << 'non-publishable' unless can_modify && current_user.able_to?(:publish_content) + options[:class] << 'non-editable' unless can_modify && current_cms_user.able_to?(:edit_content) + options[:class] << 'non-publishable' unless can_modify && current_cms_user.able_to?(:publish_content) options['data-new_path'] = url_for(new_engine_aware_path(block)) options['data-view_path'] = url_for(engine_aware_path(block, nil)) options['data-edit_path'] = url_for(edit_engine_aware_path(block)) diff --git a/app/helpers/cms/page_helper.rb b/app/helpers/cms/page_helper.rb index bcd7edd7c..ba724b51d 100644 --- a/app/helpers/cms/page_helper.rb +++ b/app/helpers/cms/page_helper.rb @@ -157,7 +157,7 @@ def render_portlet(name) # Determines if the current_user is able to do specific permissions. def able_to?(*perms, &block) - block.call if current_user.able_to?(*perms) + block.call if current_cms_user.able_to?(*perms) return '' end diff --git a/app/helpers/cms/path_helper.rb b/app/helpers/cms/path_helper.rb index 3ef192b25..0622e307f 100644 --- a/app/helpers/cms/path_helper.rb +++ b/app/helpers/cms/path_helper.rb @@ -18,7 +18,7 @@ def link_to_addressable_content(name, content) # Content editors will see exact specific version path, while other users will see the 'public' url for the path. def attachment_path_for(attachment) return "" unless attachment - if current_user.able_to?(:edit_content) + if current_cms_user.able_to?(:edit_content) attachment.attachment_version_path else attachment.url diff --git a/app/helpers/cms/rendering_helper.rb b/app/helpers/cms/rendering_helper.rb index 24ee21f07..525555138 100644 --- a/app/helpers/cms/rendering_helper.rb +++ b/app/helpers/cms/rendering_helper.rb @@ -55,7 +55,7 @@ def attachment_viewer(content) # Determines if the current user can edit and is currently editing this content. def is_current_user_able_to_edit_this_content?(content) - content && logged_in? && edit_mode? && current_user.able_to_edit?(content) + content && logged_in? && edit_mode? && current_cms_user.able_to_edit?(content) end # @deprecated diff --git a/app/helpers/cms/ui_elements_helper.rb b/app/helpers/cms/ui_elements_helper.rb index 0f99ba19e..703ce93cd 100644 --- a/app/helpers/cms/ui_elements_helper.rb +++ b/app/helpers/cms/ui_elements_helper.rb @@ -32,7 +32,7 @@ def bottom_buttons(form, partial_name="buttons") # 1. Current User has publish rights # 2. Block is publishable def save_and_publish_button(block, content_type) - if current_user.able_to?(:publish_content) && block.publishable? + if current_cms_user.able_to?(:publish_content) && block.publishable? html = %Q{} html.html_safe end @@ -50,7 +50,7 @@ def publish_button(type) def publish_menu_button(content_item) options = {class: ["btn", "btn-primary", "http_put"], id: "publish_button"} path = "#" - if current_user.able_to?(:publish_content) && !content_item.new_record? && content_item.respond_to?(:live?) && !content_item.live? + if current_cms_user.able_to?(:publish_content) && !content_item.new_record? && content_item.respond_to?(:live?) && !content_item.live? path = engine(@block).polymorphic_path([:publish, @block]) else options[:class] << "disabled" @@ -118,7 +118,7 @@ def versions_menu_button(content_item) # def delete_menu_button(content_item=nil, opts={class: []}) classes = ["btn", "http_delete", "confirm_with_title"] - if current_user.able_to_publish?(content_item) + if current_cms_user.able_to_publish?(content_item) classes << 'btn-primary' else classes << 'disabled' diff --git a/app/models/cms/portlet.rb b/app/models/cms/portlet.rb index 03057599c..201a99487 100644 --- a/app/models/cms/portlet.rb +++ b/app/models/cms/portlet.rb @@ -25,7 +25,7 @@ def self.description(description="") delegate :request, :response, :session, :flash, :params, :cookies, - :current_user, :logged_in?, + :current_cms_user, :logged_in?, :to => :controller def self.inherited(subclass) diff --git a/app/views/cms/content_block/render_block_in_main_container.html.erb b/app/views/cms/content_block/render_block_in_main_container.html.erb index b6963a8d0..4330829ea 100644 --- a/app/views/cms/content_block/render_block_in_main_container.html.erb +++ b/app/views/cms/content_block/render_block_in_main_container.html.erb @@ -1,4 +1,4 @@ -<% if current_user.able_to_edit?(@block) %> +<% if current_cms_user.able_to_edit?(@block) %> <% content_for :html_head do %> <%= javascript_include_tag 'cms/page_editor' %> <%= stylesheet_link_tag 'cms/page_content_editing' %> diff --git a/app/views/cms/pages/_form.html.erb b/app/views/cms/pages/_form.html.erb index 194edc09e..66a4e7b48 100644 --- a/app/views/cms/pages/_form.html.erb +++ b/app/views/cms/pages/_form.html.erb @@ -6,7 +6,7 @@ <% content_for :sidebar do %>