5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 06:56:22 +00:00

fix: detección de spambots y reporte anónimo

This commit is contained in:
f 2024-10-31 11:17:21 -03:00
parent ec8ea41da5
commit 93ad72f86d
No known key found for this signature in database

View file

@ -10,11 +10,32 @@ class RegistrationsController < Devise::RegistrationsController
private 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 def anti_spambot_traps
raise SpambotError if params.dig(:usuarie, :name).blank? raise SpambotError if spambot?
rescue SpambotError => e rescue SpambotError => e
ExceptionNotifier.notify_exception(e, data: { params: params }) ExceptionNotifier.notify_exception(e, data: { params: anonymized_params })
nil nil
end 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 end