From df84cdf698ec1e0e7db9b1b0609ef9df05276972 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Wed, 16 Sep 2015 22:08:08 -0300 Subject: [PATCH] rails4: make login possible without touching user_data --- app/controllers/application_controller.rb | 2 -- lib/authenticated_system.rb | 7 +++++-- vendor/plugins/noosfero_caching/init.rb | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 121a877..d1574ee 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,9 +8,7 @@ class ApplicationController < ActionController::Base before_filter :init_noosfero_plugins before_filter :allow_cross_domain_access - # AuthenticatedSystem filters must come before login_from_cookie include AuthenticatedSystem - before_filter :login_from_cookie before_filter :login_required, :if => :private_environment? before_filter :verify_members_whitelist, :if => [:private_environment?, :user] diff --git a/lib/authenticated_system.rb b/lib/authenticated_system.rb index 245a77b..e23b576 100644 --- a/lib/authenticated_system.rb +++ b/lib/authenticated_system.rb @@ -3,8 +3,10 @@ module AuthenticatedSystem protected def self.included base - # See impl. from http://stackoverflow.com/a/2513456/670229 - base.around_filter :user_set_current if base.is_a? ActionController::Base + if base.is_a? ActionController::Base + base.around_filter :user_set_current + base.before_filter :login_from_cookie + end # Inclusion hook to make #current_user and #logged_in? # available as ActionView helper methods. @@ -40,6 +42,7 @@ module AuthenticatedSystem @current_user = User.current = new_user end + # See impl. from http://stackoverflow.com/a/2513456/670229 def user_set_current User.current = current_user yield diff --git a/vendor/plugins/noosfero_caching/init.rb b/vendor/plugins/noosfero_caching/init.rb index dd6dae2..0521439 100644 --- a/vendor/plugins/noosfero_caching/init.rb +++ b/vendor/plugins/noosfero_caching/init.rb @@ -27,7 +27,7 @@ module NoosferoHttpCaching end def noosfero_session_check - return if (params[:controller] == 'account' && params[:action] != 'user_data') + return unless params[:controller] == 'account' headers["X-Noosfero-Auth"] = (session[:user] != nil).to_s end -- libgit2 0.21.2