card-mod-recaptcha 0.11.2 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/initializers/recaptcha.rb +4 -0
- data/set/all/recaptcha.rb +6 -6
- data/set/self/admin_info.rb +4 -4
- data/set/self/captcha.rb +5 -0
- data/set/self/recaptcha_settings.rb +9 -8
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c2b0d1c3a503a2e96ecc5deb5afa81ab72d6b614a27d7e0e98943ca9d53cb58
|
4
|
+
data.tar.gz: f4daf9215457fe80825410bccd50f631f551fe1388ae286d3c23bb86d8a2d0e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 119ad46d91612c8e84831d7ae808f5878cd5d0966fbd31cc518c3ce942b3f90b4408f4a8d3423e87fd606040f4738e910bc952648cc2da7fb08409090ec751f0
|
7
|
+
data.tar.gz: 8e22bd8cb728806aeea960b69b339cfae5a4c2d7d13ff5ddfb6d1bdfa91e81c3d48675210a8b57535169cbbdd54033c30c5d94cd7d3736ba70a5529d3b69f2c4
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
|
2
3
|
require "recaptcha"
|
3
4
|
|
4
5
|
# This initializer module is mostly here to avoid adding methods/vars to the Object
|
@@ -39,6 +40,7 @@ module RecaptchaCard
|
|
39
40
|
|
40
41
|
def card_value setting
|
41
42
|
return unless Card::Codename.exist? setting # prevents breakage in migrations
|
43
|
+
|
42
44
|
value = Card[setting]&.content
|
43
45
|
value if value.present?
|
44
46
|
end
|
@@ -53,3 +55,5 @@ ActiveSupport.on_load :after_card do
|
|
53
55
|
config.verify_url = "https://www.google.com/recaptcha/api/siteverify"
|
54
56
|
end
|
55
57
|
end
|
58
|
+
|
59
|
+
CardController.include ::Recaptcha::Verify
|
data/set/all/recaptcha.rb
CHANGED
@@ -33,9 +33,9 @@ def add_recaptcha_errors error_codes
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def recaptcha_success? result
|
36
|
-
result[
|
37
|
-
(result[
|
38
|
-
(result[
|
36
|
+
result["success"] &&
|
37
|
+
(result["score"].to_f >= Cardio.config.recaptcha_minimum_score) &&
|
38
|
+
(result["action"].to_sym == action.to_sym)
|
39
39
|
end
|
40
40
|
|
41
41
|
def recaptcha_response
|
@@ -55,16 +55,16 @@ event :recaptcha, :validate, when: :validate_recaptcha? do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def handle_recaptcha_config_errors
|
58
|
-
|
58
|
+
case Env.params[:recaptcha_token]
|
59
|
+
when "grecaptcha-undefined"
|
59
60
|
errors.add "recaptcha", "needs correct v3 configuration" # LOCALILZE
|
60
|
-
|
61
|
+
when "recaptcha-token-field-missing"
|
61
62
|
raise Card::Error, "recaptcha token field missing" # LOCALILZE
|
62
63
|
else
|
63
64
|
yield
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
67
|
-
|
68
68
|
def validate_recaptcha?
|
69
69
|
!@supercard && !Env[:recaptcha_used] && recaptcha_on?
|
70
70
|
end
|
data/set/self/admin_info.rb
CHANGED
@@ -11,17 +11,17 @@ format :html do
|
|
11
11
|
# %(Your captcha is currently working with temporary settings.
|
12
12
|
# This is fine for a local installation, but you will need new
|
13
13
|
# recaptcha keys if you want to make this site public.)
|
14
|
-
|
14
|
+
t :recaptcha_captcha_temp, recaptcha_link: add_recaptcha_keys_link
|
15
15
|
else
|
16
16
|
# %(You are configured to use [[*captcha]], but for that to work
|
17
17
|
# you need new recaptcha keys.)
|
18
|
-
|
19
|
-
|
18
|
+
t :recaptcha_captcha_keys, recaptcha_link: add_recaptcha_keys_link,
|
19
|
+
captcha_link: link_to_card(:captcha)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def add_recaptcha_keys_link
|
25
|
-
Card[:recaptcha_settings]&.format&.edit_link link_text:
|
25
|
+
Card[:recaptcha_settings]&.format&.edit_link link_text: t(:recaptcha_captcha_keys)
|
26
26
|
end
|
27
27
|
end
|
data/set/self/captcha.rb
ADDED
@@ -12,19 +12,20 @@ format :html do
|
|
12
12
|
# end
|
13
13
|
#
|
14
14
|
# <h5>#{instructions}</h5>
|
15
|
-
# #{
|
15
|
+
# #{howto_add_keys}
|
16
16
|
# #{howto_turn_captcha_off}
|
17
17
|
#
|
18
18
|
# def howto_add_new_recaptcha_keys
|
19
|
-
# instructions
|
20
|
-
# [
|
21
|
-
#
|
22
|
-
#
|
19
|
+
# instructions t(:recaptcha_howto_add_keys),
|
20
|
+
# [t(:recaptcha_howto_register,
|
21
|
+
# recaptcha_link: link_to_resource("http://google.com/recaptcha")),
|
22
|
+
# t(:recaptcha_howto_add,
|
23
|
+
# recaptcha_settings: link_to_card(:recaptcha_settings))]
|
23
24
|
# end
|
24
25
|
#
|
25
26
|
# def howto_turn_captcha_off
|
26
|
-
# instructions
|
27
|
-
# [
|
28
|
-
#
|
27
|
+
# instructions t(:recaptcha_howto_turn_off),
|
28
|
+
# [t(:recaptcha_howto_go, captcha_card: link_to_card(:captcha)),
|
29
|
+
# t(:recaptcha_howto_update)]
|
29
30
|
# end
|
30
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card-mod-recaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-07-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: card
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.102.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.
|
28
|
+
version: 1.102.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: recaptcha
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- config/initializers/recaptcha.rb
|
51
51
|
- set/all/recaptcha.rb
|
52
52
|
- set/self/admin_info.rb
|
53
|
+
- set/self/captcha.rb
|
53
54
|
- set/self/recaptcha_proxy.rb
|
54
55
|
- set/self/recaptcha_secret_key.rb
|
55
56
|
- set/self/recaptcha_settings.rb
|
@@ -79,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
80
|
- !ruby/object:Gem::Version
|
80
81
|
version: '0'
|
81
82
|
requirements: []
|
82
|
-
rubygems_version: 3.
|
83
|
+
rubygems_version: 3.2.15
|
83
84
|
signing_key:
|
84
85
|
specification_version: 4
|
85
86
|
summary: recaptcha support for decko
|