4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/turnstile/controller_methods.rb', line 4
def valid_captcha?(*args)
return true unless Turnstile.configuration.enabled
options = args.
verification = Turnstile::Verification.new(response: params["cf-turnstile-response"], remote_ip: request.remote_ip)
return true if verification.success?
Turnstile.configuration.on_failure&.call(verification)
if options[:model].respond_to?(:errors)
options[:model].errors.add(:base, :invalid_captcha, message: "Captcha verification failed")
end
false
end
|