recaptcha 5.4.1 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/lib/recaptcha.rb +7 -1
- data/lib/recaptcha/adapters/controller_methods.rb +7 -1
- data/lib/recaptcha/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba681f9321310ca16bb41dc622bf7051c30df10ec000582f9dd8d29310e21136
|
4
|
+
data.tar.gz: 8d9a3a4a7adb2ea830f17ace469e6b475d4d5c633c6988cd04dd56a7fd70e414
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efba5551493debe23617c41db429c224f51a4d0253274cf6fe28c5e384d78f4bd374ba3ad3132c2009cb2df9813266ac3a90eabd9a019aa7d48ee3999f2451e3
|
7
|
+
data.tar.gz: 1dfd4f2281c8f6902b1c70ca0d272d0d2f671d9062669f147cfb38416ee771e7348ff131c8fd957c1e8674b7d83ad3f3c79f6c306a7779638b4481000534f695
|
data/README.md
CHANGED
@@ -440,6 +440,22 @@ are passed as a hash under `params['g-recaptcha-response-data']` with the action
|
|
440
440
|
It is recommended to pass `external_script: false` on all but one of the calls to
|
441
441
|
`recaptcha` since you only need to include the script tag once for a given `site_key`.
|
442
442
|
|
443
|
+
## `recaptcha_reply`
|
444
|
+
|
445
|
+
After `verify_recaptcha` has been called, you can call `recaptcha_reply` to get the raw reply from recaptcha. This can allow you to get the exact score returned by recaptcha should you need it.
|
446
|
+
|
447
|
+
```ruby
|
448
|
+
if verify_recaptcha(action: 'login')
|
449
|
+
redirect_to @user
|
450
|
+
else
|
451
|
+
score = recaptcha_reply['score']
|
452
|
+
Rails.logger.warn("User #{@user.id} was denied login because of a recaptcha score of #{score}")
|
453
|
+
render 'new'
|
454
|
+
end
|
455
|
+
```
|
456
|
+
|
457
|
+
`recaptcha_reply` will return `nil` if the the reply was not yet fetched.
|
458
|
+
|
443
459
|
## I18n support
|
444
460
|
|
445
461
|
reCAPTCHA supports the I18n gem (it comes with English translations)
|
data/lib/recaptcha.rb
CHANGED
@@ -65,10 +65,16 @@ module Recaptcha
|
|
65
65
|
verify_hash['remoteip'] = options[:remote_ip] if options.key?(:remote_ip)
|
66
66
|
|
67
67
|
reply = api_verification(verify_hash, timeout: options[:timeout])
|
68
|
-
reply['success'].to_s == 'true' &&
|
68
|
+
success = reply['success'].to_s == 'true' &&
|
69
69
|
hostname_valid?(reply['hostname'], options[:hostname]) &&
|
70
70
|
action_valid?(reply['action'], options[:action]) &&
|
71
71
|
score_above_threshold?(reply['score'], options[:minimum_score])
|
72
|
+
|
73
|
+
if options[:with_reply] == true
|
74
|
+
return success, reply
|
75
|
+
else
|
76
|
+
return success
|
77
|
+
end
|
72
78
|
end
|
73
79
|
|
74
80
|
def self.hostname_valid?(hostname, validation)
|
@@ -24,7 +24,9 @@ module Recaptcha
|
|
24
24
|
options = options.merge(remote_ip: remoteip.to_s) if remoteip
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
success, @_recaptcha_reply =
|
28
|
+
Recaptcha.verify_via_api_call(recaptcha_response, options.merge(with_reply: true))
|
29
|
+
success
|
28
30
|
end
|
29
31
|
|
30
32
|
if verified
|
@@ -58,6 +60,10 @@ module Recaptcha
|
|
58
60
|
verify_recaptcha(options) || raise(VerifyError)
|
59
61
|
end
|
60
62
|
|
63
|
+
def recaptcha_reply
|
64
|
+
@_recaptcha_reply if defined?(@_recaptcha_reply)
|
65
|
+
end
|
66
|
+
|
61
67
|
def recaptcha_error(model, attribute, message)
|
62
68
|
if model
|
63
69
|
model.errors.add(attribute, message)
|
data/lib/recaptcha/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason L Perry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|