implantação da fase 2 e 3

This commit is contained in:
2026-06-10 20:12:20 -03:00
parent d37237ead2
commit 472484798f
33 changed files with 2915 additions and 430 deletions

View File

@@ -4,24 +4,26 @@ class ApplicationController < ActionController::Base
before_action :authenticate_user!
before_action :set_tema
after_action :verify_authorized, except: :index, unless: :skip_pundit?
after_action :verify_policy_scoped, only: :index, unless: :skip_pundit?
# Pundit: redireciona se não autorizado
rescue_from Pundit::NotAuthorizedError do |e|
flash[:alert] = "Você não tem permissão para realizar esta ação."
redirect_to root_path
end
rescue_from Pundit::NotAuthorizedError, with: :usuario_nao_autorizado
protect_from_forgery with: :exception
private
def set_tema
@tema = current_user&.tema_preferido || 'dark'
# Lê o tema da sessão (padrão: escuro)
@tema = session[:tema] || 'dark'
end
def after_sign_in_path_for(resource)
if resource.motorista?
motorista_dashboard_path
else
dashboard_path
end
def skip_pundit?
devise_controller? || params[:controller] =~ /rails\/|action_mailbox|action_text/
end
def usuario_nao_autorizado
flash[:alert] = 'Acesso negado. Você não tem permissão para esta ação.'
redirect_back(fallback_location: dashboard_path)
end
end