demarches-normaliennes/app/controllers/root_controller.rb

44 lines
1.3 KiB
Ruby
Raw Normal View History

class RootController < ApplicationController
def index
route = Rails.application.routes.recognize_path(request.referrer)
if Features.opensimplif
unless !user_signed_in? && !administrateur_signed_in? && !gestionnaire_signed_in?
return redirect_to simplifications_path
end
end
2016-12-07 14:39:06 +01:00
if user_signed_in? && !route[:controller].match('users').nil?
return redirect_to users_dossiers_path
2016-12-19 16:54:41 +01:00
elsif administrateur_signed_in? && !route[:controller].match('admin').nil?
return redirect_to admin_procedures_path
elsif gestionnaire_signed_in?
2016-12-14 18:41:33 +01:00
procedure_id = current_gestionnaire.procedure_filter
if procedure_id.nil?
procedure_list = current_gestionnaire.procedures
2016-12-14 18:41:33 +01:00
if procedure_list.count > 0
return redirect_to backoffice_dossiers_procedure_path(id: procedure_list.first.id)
else
flash.alert = "Vous n'avez aucune procédure d'affectée"
end
2016-12-19 16:54:41 +01:00
else
return redirect_to backoffice_dossiers_procedure_path(id: procedure_id)
2016-12-14 18:41:33 +01:00
end
2016-12-19 16:54:41 +01:00
elsif user_signed_in?
2016-12-14 18:41:33 +01:00
return redirect_to users_dossiers_path
elsif administrateur_signed_in?
2016-12-14 18:41:33 +01:00
return redirect_to admin_procedures_path
2016-02-23 16:51:24 +01:00
elsif administration_signed_in?
2016-12-14 18:41:33 +01:00
return redirect_to administrations_path
end
2016-12-14 18:41:33 +01:00
render 'landing'
end
end