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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -0
- data/lib/rucaptcha/controller_helpers.rb +18 -2
- data/lib/rucaptcha/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '00804da70361b1a618dfd59562716e0f46d6d4c8'
|
4
|
+
data.tar.gz: 101fe45e4d3693995d92ee2464332cd79b314eea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4742b71125d27a0e1ed88cf613d392b6df8d47549c9b4431e9a84c68b31d7da2765b30dbdf15712ccb4bc684f71ddc2f581ff6b8b0045bb3592ca2333a0d93c8
|
7
|
+
data.tar.gz: a51e67942ad72ecf926343f838f1ca285bb9f8af8a7636f33b6289a954a8e514060f049514360514acc0a526a30d394c5f97eb557a9e85a14141cc0b894f22f1
|
data/CHANGELOG.md
CHANGED
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
|
-
|
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?
|
data/lib/rucaptcha/version.rb
CHANGED
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.
|
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
|
+
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.
|
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
|