2015-06-10 03:59:39 -04:00
|
|
|
# RootController
|
|
|
|
#
|
|
|
|
# This controller exists solely to handle requests to `root_url`. When a user is
|
|
|
|
# logged in and has customized their `dashboard` setting, they will be
|
|
|
|
# redirected to their preferred location.
|
|
|
|
#
|
|
|
|
# For users who haven't customized the setting, we simply delegate to
|
|
|
|
# `DashboardController#show`, which is the default.
|
2015-09-08 09:49:20 -04:00
|
|
|
class RootController < Dashboard::ProjectsController
|
2017-01-28 21:22:13 -05:00
|
|
|
skip_before_action :authenticate_user!, only: [:index]
|
2015-09-09 04:25:49 -04:00
|
|
|
before_action :redirect_to_custom_dashboard, only: [:index]
|
2015-06-12 20:53:58 -04:00
|
|
|
|
2015-09-08 09:49:20 -04:00
|
|
|
def index
|
2015-06-12 20:53:58 -04:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def redirect_to_custom_dashboard
|
2017-01-28 21:22:13 -05:00
|
|
|
return redirect_to new_user_session_path unless current_user
|
2015-06-12 20:53:58 -04:00
|
|
|
|
|
|
|
case current_user.dashboard
|
2015-06-10 03:59:39 -04:00
|
|
|
when 'stars'
|
2015-09-08 09:49:20 -04:00
|
|
|
flash.keep
|
2015-06-10 03:59:39 -04:00
|
|
|
redirect_to starred_dashboard_projects_path
|
2015-09-25 20:04:20 -04:00
|
|
|
when 'project_activity'
|
|
|
|
redirect_to activity_dashboard_path
|
|
|
|
when 'starred_project_activity'
|
|
|
|
redirect_to activity_dashboard_path(filter: 'starred')
|
2016-03-24 06:12:45 -04:00
|
|
|
when 'groups'
|
|
|
|
redirect_to dashboard_groups_path
|
|
|
|
when 'todos'
|
|
|
|
redirect_to dashboard_todos_path
|
2015-06-10 03:59:39 -04:00
|
|
|
else
|
2015-06-12 20:53:58 -04:00
|
|
|
return
|
2015-06-10 03:59:39 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|