From 41d7be3ce1ae9a4bff93b62322f35989b6ad4cf6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 16 Jan 2015 16:01:15 -0800 Subject: Allow to specify home page for non logged-in users --- app/controllers/application_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b83de68c5d2..4780a7a2a9a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -48,6 +48,17 @@ class ApplicationController < ActionController::Base end end + def authenticate_user! + # If user is not signe-in and tries to access root_path - redirect him to landing page + if current_application_settings.home_page_url.present? + if current_user.nil? && controller_name == 'dashboard' && action_name == 'show' + redirect_to current_application_settings.home_page_url and return + end + end + + super + end + def log_exception(exception) application_trace = ActionDispatch::ExceptionWrapper.new(env, exception).application_trace application_trace.map!{ |t| " #{t}\n" } -- cgit v1.2.1 From f2eb234c068ccb57f100080a499d307b9b2f5502 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 16 Jan 2015 18:12:15 -0800 Subject: Fix passign args to original authenticate_user! --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4780a7a2a9a..6da4f91c3f4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -48,7 +48,7 @@ class ApplicationController < ActionController::Base end end - def authenticate_user! + def authenticate_user!(*args) # If user is not signe-in and tries to access root_path - redirect him to landing page if current_application_settings.home_page_url.present? if current_user.nil? && controller_name == 'dashboard' && action_name == 'show' @@ -56,7 +56,7 @@ class ApplicationController < ActionController::Base end end - super + super(*args) end def log_exception(exception) -- cgit v1.2.1