invisible_captcha 0.12.1 → 0.12.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0904f2d5218d84ee62e3328259b217c7a3772497c8ecf47ed94a34b4bc083f8
4
- data.tar.gz: a2e806057b7cbe29927bbb705e342426b666cbc5c6bc823fe97434d912b322cc
3
+ metadata.gz: 5011fee9db065c86faf1507c11e0d3000ad61e19d05e7102e8bcf3750abcd52f
4
+ data.tar.gz: bd104ffe4aeb3436c1d365a293c66f80d9d2e42c543b009ea596ac83d9a84db2
5
5
  SHA512:
6
- metadata.gz: 9f0ac495f41f5937859077d758e88884e369aa534d97b595fd4dc560923ce8cb9deb31bd3c487f33d04c82878eeed9ada45508b511e8ff77320d762979f0ea7d
7
- data.tar.gz: 953bfa53bf999143d76c45f785e11e80e8fbd44a20fc0182c6d87e009ece31610f9b699049e01e01b6fcfeb887de968a656f1dd437973a5d54e8d43cc6c170bb
6
+ metadata.gz: e1c5608b8671bfef9edfec01531f575fe3a83c12a00dd72090a772686f2fef56ab6436e323dc7ca7daa1b82d30764ca03a2f89d6727145f593d377d1c057fe51
7
+ data.tar.gz: 811827be3f2a2bd4a18a1004377605c8db09c1279658371d2191e27226afd6557235c8747a5c39ec82a65bc443bb4590dcced9fff96d8be4fba946d21a07a50d
data/Appraisals CHANGED
@@ -1,5 +1,5 @@
1
1
  appraise "rails-6.0" do
2
- gem "rails", "6.0.0.rc1"
2
+ gem "rails", "~> 6.0.0"
3
3
  end
4
4
 
5
5
  appraise "rails-5.2" do
@@ -20,4 +20,4 @@ end
20
20
 
21
21
  appraise "rails-3.2" do
22
22
  gem "rails", "~> 3.2.0"
23
- end
23
+ end
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.12.2]
6
+
7
+ - Allow new timestamp to be set during `on_timestamp_spam` callback (#53)
8
+
5
9
  ## [0.12.1]
6
10
 
7
11
  - Clear timestamp stored in `session[:invisible_captcha_timestamp]` (#50)
@@ -97,6 +101,7 @@ All notable changes to this project will be documented in this file.
97
101
 
98
102
  - First version of controller filters
99
103
 
104
+ [0.12.2]: https://github.com/markets/invisible_captcha/compare/v0.12.1...v0.12.2
100
105
  [0.12.1]: https://github.com/markets/invisible_captcha/compare/v0.12.0...v0.12.1
101
106
  [0.12.0]: https://github.com/markets/invisible_captcha/compare/v0.11.0...v0.12.0
102
107
  [0.11.0]: https://github.com/markets/invisible_captcha/compare/v0.10.0...v0.11.0
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "6.0.0.rc1"
5
+ gem "rails", "~> 6.0.0"
6
6
 
7
7
  gemspec path: "../"
@@ -22,8 +22,6 @@ module InvisibleCaptcha
22
22
  elsif honeypot_spam?(options)
23
23
  on_spam(options)
24
24
  end
25
-
26
- clear_session
27
25
  end
28
26
 
29
27
  def on_timestamp_spam(options = {})
@@ -55,15 +53,15 @@ module InvisibleCaptcha
55
53
 
56
54
  return false unless enabled
57
55
 
58
- timestamp = session[:invisible_captcha_timestamp]
56
+ @invisible_captcha_timestamp ||= session.delete(:invisible_captcha_timestamp)
59
57
 
60
58
  # Consider as spam if timestamp not in session, cause that means the form was not fetched at all
61
- unless timestamp
59
+ unless @invisible_captcha_timestamp
62
60
  warn("Invisible Captcha timestamp not found in session.")
63
61
  return true
64
62
  end
65
63
 
66
- time_to_submit = Time.zone.now - DateTime.iso8601(timestamp)
64
+ time_to_submit = Time.zone.now - DateTime.iso8601(@invisible_captcha_timestamp)
67
65
  threshold = options[:timestamp_threshold] || InvisibleCaptcha.timestamp_threshold
68
66
 
69
67
  # Consider as spam if form submitted too quickly
@@ -72,11 +70,7 @@ module InvisibleCaptcha
72
70
  return true
73
71
  end
74
72
 
75
- false
76
- end
77
-
78
- def clear_session
79
- session.delete(:invisible_captcha_timestamp) if session[:invisible_captcha_timestamp]
73
+ return false
80
74
  end
81
75
 
82
76
  def honeypot_spam?(options = {})
@@ -1,3 +1,3 @@
1
1
  module InvisibleCaptcha
2
- VERSION = "0.12.1"
2
+ VERSION = "0.12.2"
3
3
  end
@@ -63,12 +63,25 @@ RSpec.describe InvisibleCaptcha::ControllerExt, type: :controller do
63
63
  expect(session[:invisible_captcha_timestamp]).to be_nil
64
64
  end
65
65
 
66
- it 'allow a custom on_timestamp_spam callback' do
66
+ it 'allows a custom on_timestamp_spam callback' do
67
67
  switchable_put :update, id: 1, topic: { title: 'bar' }
68
68
 
69
69
  expect(response.status).to eq(204)
70
70
  end
71
71
 
72
+ it 'allows a new timestamp to be set in the on_timestamp_spam callback' do
73
+ @controller.singleton_class.class_eval do
74
+ def custom_timestamp_callback
75
+ session[:invisible_captcha_timestamp] = 2.seconds.from_now(Time.zone.now).iso8601
76
+ head(204)
77
+ end
78
+ end
79
+
80
+ expect { switchable_put :update, id: 1, topic: { title: 'bar' } }
81
+ .to change { session[:invisible_captcha_timestamp] }
82
+ .to be_present
83
+ end
84
+
72
85
  context 'successful submissions' do
73
86
  it 'passes if submission on or after timestamp_threshold' do
74
87
  sleep InvisibleCaptcha.timestamp_threshold
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invisible_captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Anguera Insa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-27 00:00:00.000000000 Z
11
+ date: 2019-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails