Adição da tela de animação no login
This commit is contained in:
@@ -5,6 +5,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
before_action :authenticate_user!
|
||||
before_action :set_tema
|
||||
before_action :preparar_splash
|
||||
|
||||
# Pundit: redireciona se não autorizado
|
||||
rescue_from Pundit::NotAuthorizedError do |e|
|
||||
@@ -18,11 +19,17 @@ class ApplicationController < ActionController::Base
|
||||
@tema = current_user&.tema_preferido || 'dark'
|
||||
end
|
||||
|
||||
# Mostra a animação de abertura uma única vez, na primeira página HTML após o
|
||||
# login. O flag é gravado em #after_sign_in_path_for (Devise) e nos logins do
|
||||
# motorista (PIN/QR); aqui ele é lido e apagado (one-shot).
|
||||
def preparar_splash
|
||||
return unless request.get? && request.format.html?
|
||||
|
||||
@mostrar_splash = session.delete(:mostrar_splash)
|
||||
end
|
||||
|
||||
def after_sign_in_path_for(resource)
|
||||
if resource.motorista?
|
||||
motorista_dashboard_path
|
||||
else
|
||||
dashboard_path
|
||||
end
|
||||
session[:mostrar_splash] = true
|
||||
resource.motorista? ? motorista_dashboard_path : dashboard_path
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user