diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 353d0c17..c9f21b53 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -10,11 +10,32 @@ class RegistrationsController < Devise::RegistrationsController private - # Detecta spambots simples + # Condiciones bajo las que consideramos que un registro viene de unx + # spambot + # + # @return [Bool] + def spambot? + @spambot ||= params.dig(:usuarie, :name).present? + end + + # Detecta e informa spambots muy simples + # + # @return [nil] def anti_spambot_traps - raise SpambotError if params.dig(:usuarie, :name).blank? + raise SpambotError if spambot? rescue SpambotError => e - ExceptionNotifier.notify_exception(e, data: { params: params }) + ExceptionNotifier.notify_exception(e, data: { params: anonymized_params }) nil end + + # Devuelve parámetros anonimizados para prevenir filtrar la contraseña + # de falsos positivos. + # + # @return [Hash] + def anonymized_params + params.except(:authenticity_token).permit!.to_h.tap do |p| + p['usuarie'].delete 'password' + p['usuarie'].delete 'password_confirmation' + end + end end