rucaptcha 1.1.4 → 1.2.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
  SHA1:
3
- metadata.gz: 7b416a66df71165fcd0c026e7aafbb858e1b3e39
4
- data.tar.gz: e796e5f306d7b8a4f73bf46cf598257761caae9e
3
+ metadata.gz: '00804da70361b1a618dfd59562716e0f46d6d4c8'
4
+ data.tar.gz: 101fe45e4d3693995d92ee2464332cd79b314eea
5
5
  SHA512:
6
- metadata.gz: 9c69ac42919fd8cdfe783f570efcbb682296e4394c1e61a9ffb211abf14796eed889d0fa0b6fbb8ee58c759af9036bb93add63c1e33c418267c4139a57b107d5
7
- data.tar.gz: b60ee18e344f4ab2bc31ea6cef1e7cdbc5f69092ef93ccd860c1178e65624ed301e1e927f14ed6e0e07fd1b46f0ce4f78b6acc601558c0d772d5b8f493f6cc8e
6
+ metadata.gz: 4742b71125d27a0e1ed88cf613d392b6df8d47549c9b4431e9a84c68b31d7da2765b30dbdf15712ccb4bc684f71ddc2f581ff6b8b0045bb3592ca2333a0d93c8
7
+ data.tar.gz: a51e67942ad72ecf926343f838f1ca285bb9f8af8a7636f33b6289a954a8e514060f049514360514acc0a526a30d394c5f97eb557a9e85a14141cc0b894f22f1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 1.2.0
2
+ -----
3
+
4
+ - Add an `:keep_session` option for `verify_rucaptcha?` method to giva a way for let you keep session on verify, if true, RuCaptcha will not delete the captcha code session after validation.
5
+
1
6
  1.1.4
2
7
  -----
3
8
 
data/README.md CHANGED
@@ -99,6 +99,8 @@ class AccountController < ApplicationController
99
99
  end
100
100
  ```
101
101
 
102
+ > TIP: Sometime you may need keep last verified captcha code in session on `verify_rucaptcha?` method call, you can use `keep_session: true`. For example: ` Verify_rucaptcha? (@user, keep_session: true) `.
103
+
102
104
  View `app/views/account/new.html.erb`
103
105
 
104
106
  ```erb
@@ -6,10 +6,12 @@ module RuCaptcha
6
6
  helper_method :verify_rucaptcha?
7
7
  end
8
8
 
9
+ # session key of rucaptcha
9
10
  def rucaptcha_sesion_key_key
10
11
  ['rucaptcha-session', session.id].join(':')
11
12
  end
12
13
 
14
+ # Generate a new Captcha
13
15
  def generate_rucaptcha
14
16
  code = RuCaptcha::Captcha.random_chars
15
17
  session_val = {
@@ -20,10 +22,24 @@ module RuCaptcha
20
22
  RuCaptcha::Captcha.create(code)
21
23
  end
22
24
 
23
- def verify_rucaptcha?(resource = nil)
25
+ # Verify captcha code
26
+ #
27
+ # params:
28
+ # resource - [optional] a ActiveModel object, if given will add validation error message to object.
29
+ # :keep_session - if true, RuCaptcha will not delete the captcha code session.
30
+ #
31
+ # exmaples:
32
+ #
33
+ # verify_rucaptcha?
34
+ # verify_rucaptcha?(user, keep_session: true)
35
+ # verify_rucaptcha?(nil, keep_session: true)
36
+ #
37
+ def verify_rucaptcha?(resource = nil, opts = {})
38
+ opts ||= {}
39
+
24
40
  store_info = RuCaptcha.cache.read(rucaptcha_sesion_key_key)
25
41
  # make sure move used key
26
- RuCaptcha.cache.delete(rucaptcha_sesion_key_key)
42
+ RuCaptcha.cache.delete(rucaptcha_sesion_key_key) unless opts[:keep_session]
27
43
 
28
44
  # Make sure session exist
29
45
  if store_info.blank?
@@ -1,3 +1,3 @@
1
1
  module RuCaptcha
2
- VERSION = '1.1.4'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rucaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-09 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  requirements: []
68
68
  rubyforge_project:
69
- rubygems_version: 2.4.8
69
+ rubygems_version: 2.5.2
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: This is a Captcha gem for Rails Application. It run ImageMagick command to