recaptcha 3.0.0 → 3.1.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/CHANGELOG.md +3 -0
- data/lib/recaptcha.rb +2 -3
- data/lib/recaptcha/client_helper.rb +10 -5
- data/lib/recaptcha/verify.rb +8 -8
- data/lib/recaptcha/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca2ec26c375c95c1459db34eda553e75cbfaa1b1
|
4
|
+
data.tar.gz: 85136cf39a2bcc76269935fde5265a60162d3a80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7280548570fb6c61c15e18f6ad6f533b06b1df491e7b31f26ad5fcf99b40ff9a5e737dfbf70106b5e96ffd8cd457809459092d693a0450730fbf3a6dae4b5f17
|
7
|
+
data.tar.gz: b002273c513e292f91d5febca4bc37264ddd0495f3b38b7e90781cc647d1a7eda5471a8123b4d479da7845b5d5df6600864560493fd1d72832d23490d1f70c18
|
data/CHANGELOG.md
CHANGED
data/lib/recaptcha.rb
CHANGED
@@ -8,11 +8,11 @@ module Recaptcha
|
|
8
8
|
CONFIG = {
|
9
9
|
'server_url' => 'https://www.google.com/recaptcha/api.js',
|
10
10
|
'verify_url' => 'https://www.google.com/recaptcha/api/siteverify'
|
11
|
-
}
|
11
|
+
}.freeze
|
12
12
|
|
13
13
|
USE_SSL_BY_DEFAULT = false
|
14
14
|
HANDLE_TIMEOUTS_GRACEFULLY = true
|
15
|
-
SKIP_VERIFY_ENV = ['test', 'cucumber']
|
15
|
+
SKIP_VERIFY_ENV = ['test', 'cucumber'].freeze
|
16
16
|
DEFAULT_TIMEOUT = 3
|
17
17
|
|
18
18
|
# Gives access to the current Configuration.
|
@@ -68,7 +68,6 @@ module Recaptcha
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
71
|
class RecaptchaError < StandardError
|
73
72
|
end
|
74
73
|
|
@@ -3,8 +3,13 @@ module Recaptcha
|
|
3
3
|
# Your public API can be specified in the +options+ hash or preferably
|
4
4
|
# using the Configuration.
|
5
5
|
def recaptcha_tags(options = {})
|
6
|
-
|
7
|
-
|
6
|
+
if options.key?(:stoken)
|
7
|
+
raise(RecaptchaError, "Secure Token is deprecated. Please remove 'stoken' from your calls to recaptcha_tags.")
|
8
|
+
end
|
9
|
+
if options.key?(:ssl)
|
10
|
+
raise(RecaptchaError, "SSL is now always true. Please remove 'ssl' from your calls to recaptcha_tags.")
|
11
|
+
end
|
12
|
+
|
8
13
|
public_key = options[:public_key] || Recaptcha.configuration.public_key!
|
9
14
|
|
10
15
|
script_url = Recaptcha.configuration.api_server_url
|
@@ -16,10 +21,10 @@ module Recaptcha
|
|
16
21
|
a[k] = v if data_attributes.include?(k)
|
17
22
|
end
|
18
23
|
data_attributes[:sitekey] = public_key
|
19
|
-
data_attributes = data_attributes.map { |k,v| %
|
24
|
+
data_attributes = data_attributes.map { |k, v| %(data-#{k.to_s.tr('_', '-')}="#{v}") }.join(" ")
|
20
25
|
|
21
|
-
html = %
|
22
|
-
html << %
|
26
|
+
html = %(<script src="#{script_url}" async defer></script>\n)
|
27
|
+
html << %(<div class="g-recaptcha" #{data_attributes}></div>\n)
|
23
28
|
|
24
29
|
if options[:noscript] != false
|
25
30
|
html << <<-HTML
|
data/lib/recaptcha/verify.rb
CHANGED
@@ -5,7 +5,7 @@ module Recaptcha
|
|
5
5
|
# Your private API can be specified in the +options+ hash or preferably
|
6
6
|
# using the Configuration.
|
7
7
|
def verify_recaptcha(options = {})
|
8
|
-
options = {:
|
8
|
+
options = {model: options} unless options.is_a? Hash
|
9
9
|
return true if Recaptcha::Verify.skip?(options[:env])
|
10
10
|
|
11
11
|
model = options[:model]
|
@@ -51,7 +51,12 @@ module Recaptcha
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def verify_recaptcha!(options = {})
|
54
|
-
verify_recaptcha(options)
|
54
|
+
verify_recaptcha(options) || raise(VerifyError)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.skip?(env)
|
58
|
+
env ||= ENV['RACK_ENV'] || ENV['RAILS_ENV'] || (Rails.env if defined? Rails.env)
|
59
|
+
Recaptcha.configuration.skip_verify_env.include? env
|
55
60
|
end
|
56
61
|
|
57
62
|
private
|
@@ -82,7 +87,7 @@ module Recaptcha
|
|
82
87
|
end
|
83
88
|
|
84
89
|
def recaptcha_error(model, attribute, message, key, default)
|
85
|
-
message
|
90
|
+
message ||= Recaptcha.i18n(key, default)
|
86
91
|
if model
|
87
92
|
model.errors.add attribute, message
|
88
93
|
else
|
@@ -93,10 +98,5 @@ module Recaptcha
|
|
93
98
|
def recaptcha_flash_supported?
|
94
99
|
request.respond_to?(:format) && request.format == :html && respond_to?(:flash)
|
95
100
|
end
|
96
|
-
|
97
|
-
def self.skip?(env)
|
98
|
-
env ||= ENV['RACK_ENV'] || ENV['RAILS_ENV'] || (Rails.env if defined? Rails.env)
|
99
|
-
Recaptcha.configuration.skip_verify_env.include? env
|
100
|
-
end
|
101
101
|
end
|
102
102
|
end
|
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: 3.
|
4
|
+
version: 3.1.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: 2016-
|
11
|
+
date: 2016-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
description: Helpers for the reCAPTCHA API
|
140
154
|
email:
|
141
155
|
- jasper@ambethia.com
|