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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8f94318b9abd3ea145bde09f44015d65825cddc4ca5ee4ea1ba49bd728dca90
4
- data.tar.gz: 113dbb6d9f86f7b8df8c405822087c225b0678bda3dbdde1e50916aa365f9921
3
+ metadata.gz: 5c2b0d1c3a503a2e96ecc5deb5afa81ab72d6b614a27d7e0e98943ca9d53cb58
4
+ data.tar.gz: f4daf9215457fe80825410bccd50f631f551fe1388ae286d3c23bb86d8a2d0e1
5
5
  SHA512:
6
- metadata.gz: 01a7541383d000e633216268565cc2cfb48c77f8caed2fd968aabb6bfcf588fb741ed6f1bb958433fcaf601f451348a0bccde323410eb14447f8cddf610b1f5a
7
- data.tar.gz: a731b40026bef519717710ae46a1afd8b1177e98abe8c1728251591cc7edaff5ee4215ef931faecae46ee2f48aec36ad60e80fe21997c75c313c87fb54062b5a
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['success'] &&
37
- (result['score'].to_f >= Cardio.config.recaptcha_minimum_score) &&
38
- (result['action'].to_sym == action.to_sym)
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
- if Env.params[:recaptcha_token] == "grecaptcha-undefined"
58
+ case Env.params[:recaptcha_token]
59
+ when "grecaptcha-undefined"
59
60
  errors.add "recaptcha", "needs correct v3 configuration" # LOCALILZE
60
- elsif Env.params[:recaptcha_token] == "recaptcha-token-field-missing"
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
@@ -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
- tr :captcha_temp, recaptcha_link: add_recaptcha_keys_link
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
- tr :captcha_keys, recaptcha_link: add_recaptcha_keys_link,
19
- captcha_link: link_to_card(:captcha)
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: tr(:recaptcha_keys)
25
+ Card[:recaptcha_settings]&.format&.edit_link link_text: t(:recaptcha_captcha_keys)
26
26
  end
27
27
  end
@@ -0,0 +1,5 @@
1
+ setting_opts group: :permission,
2
+ position: 5,
3
+ help_text: "Anti-spam setting. Requires non-signed-in users to complete a "\
4
+ "[[http://decko.org/captcha|captcha]] before adding or editing "\
5
+ "cards (where permitted)."
@@ -12,19 +12,20 @@ format :html do
12
12
  # end
13
13
  #
14
14
  # <h5>#{instructions}</h5>
15
- # #{howto_add_new_recaptcha_keys}
15
+ # #{howto_add_keys}
16
16
  # #{howto_turn_captcha_off}
17
17
  #
18
18
  # def howto_add_new_recaptcha_keys
19
- # instructions tr(:howto_add_keys),
20
- # [tr(:howto_register,
21
- # recaptcha_link: link_to_resource("http://google.com/recaptcha")),
22
- # tr(:howto_add, recaptcha_settings: link_to_card(:recaptcha_settings))]
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 tr(:howto_turn_off),
27
- # [tr(:howto_go, captcha_card: link_to_card(:captcha)),
28
- # tr(:howto_update)]
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.11.2
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-03-15 00:00:00.000000000 Z
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.101.2
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.101.2
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.0.3
83
+ rubygems_version: 3.2.15
83
84
  signing_key:
84
85
  specification_version: 4
85
86
  summary: recaptcha support for decko