rucaptcha 0.1.3 → 0.1.4
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +13 -2
- data/config/locales/rucaptcha.zh-CN.yml +1 -1
- data/config/locales/rucaptcha.zh-TW.yml +1 -1
- data/lib/rucaptcha.rb +3 -1
- data/lib/rucaptcha/controller_helpers.rb +3 -3
- data/lib/rucaptcha/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696d907bf4da18cbb818072c2c9ec9bd404e4389
|
4
|
+
data.tar.gz: 0e1e1629e95bf36d0689b1fff423a67773c1e0db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87a1455083f1eb353db3dfe94f9c94e7ae648346848d15237aaa241b01ba8e0dd496b6178375957657155ed98a3b7930c41528bcffd9d56806c79051d4e5c1f6
|
7
|
+
data.tar.gz: ea055d9b0de33f891d17523bcc920d245e815b731aaaeb054f7310c459bbdffa357880cdf21847d691a3eb0ce73e90766dd4345f4be2d8649d763c8fcd7e82f6
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,8 @@ Idea by: https://ruby-china.org/topics/20558#reply4
|
|
16
16
|
|
17
17
|
### Example
|
18
18
|
|
19
|
-
    
|
20
|
+
|
20
21
|
|
21
22
|
|
22
23
|
### Usage
|
@@ -27,7 +28,7 @@ Put rucaptcha in your `Gemfile`:
|
|
27
28
|
gem 'rucaptcha'
|
28
29
|
```
|
29
30
|
|
30
|
-
Create `config/
|
31
|
+
Create `config/initializers/rucaptcha.rb`
|
31
32
|
|
32
33
|
```rb
|
33
34
|
RuCaptcha.configure do
|
@@ -40,6 +41,16 @@ RuCaptcha.configure do
|
|
40
41
|
end
|
41
42
|
```
|
42
43
|
|
44
|
+
Edit `config/routes.rb`, add the following code:
|
45
|
+
|
46
|
+
```rb
|
47
|
+
Rails.application.routes.draw do
|
48
|
+
...
|
49
|
+
mount RuCaptcha::Engine => "/rucaptcha"
|
50
|
+
...
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
43
54
|
Controller `app/controller/account_controller.rb`
|
44
55
|
|
45
56
|
```rb
|
data/lib/rucaptcha.rb
CHANGED
@@ -13,13 +13,13 @@ module RuCaptcha
|
|
13
13
|
|
14
14
|
def random_rucaptcha_chars
|
15
15
|
chars = SecureRandom.hex(RuCaptcha.config.len / 2).downcase
|
16
|
-
chars.gsub!(/[0ol1]/i, (rand(
|
16
|
+
chars.gsub!(/[0ol1]/i, (rand(8) + 2).to_s)
|
17
17
|
chars
|
18
18
|
end
|
19
19
|
|
20
20
|
def verify_rucaptcha?(resource = nil)
|
21
|
-
params[:_rucaptcha]
|
22
|
-
|
21
|
+
right = params[:_rucaptcha].present? && session[:_rucaptcha].present? &&
|
22
|
+
params[:_rucaptcha].downcase.strip == session[:_rucaptcha]
|
23
23
|
if resource && resource.respond_to?(:errors)
|
24
24
|
resource.errors.add(:base, t('rucaptcha.invalid')) unless right
|
25
25
|
end
|
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: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: posix-spawn
|