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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 712ce2bac91dc2b4f87fceb7bfd7a5766e585b20
4
- data.tar.gz: 00e1a973557977e5fc5cbf419d1c94e4acedf62c
3
+ metadata.gz: 696d907bf4da18cbb818072c2c9ec9bd404e4389
4
+ data.tar.gz: 0e1e1629e95bf36d0689b1fff423a67773c1e0db
5
5
  SHA512:
6
- metadata.gz: 75432af6e4122fe48247859a54223884ae772f98b178892d31b9c3653ad6ef7873a266c92864a50022de4dbfea8c5c164cbb8c8885ee03090b5a35d0764fc911
7
- data.tar.gz: c0766f05b40f9718a7b27d8e01d4185ee7e5f267278a1cff9838beeb7e76047d2b4dbb672bc2068fda5d44416e8d3ee0635cd500a3f18200d6529b66be861684
6
+ metadata.gz: 87a1455083f1eb353db3dfe94f9c94e7ae648346848d15237aaa241b01ba8e0dd496b6178375957657155ed98a3b7930c41528bcffd9d56806c79051d4e5c1f6
7
+ data.tar.gz: ea055d9b0de33f891d17523bcc920d245e815b731aaaeb054f7310c459bbdffa357880cdf21847d691a3eb0ce73e90766dd4345f4be2d8649d763c8fcd7e82f6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.1.4
2
+ -----
3
+
4
+ - Fix `verify_rucaptcha?` logic in somecase.
5
+ - Locales fixed.
6
+
1
7
  0.1.3
2
8
  -----
3
9
 
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
- ![simple4](https://cloud.githubusercontent.com/assets/5518/10726106/9442b1fe-7c0b-11e5-8c06-f88fce5e7a58.png) ![simple3](https://cloud.githubusercontent.com/assets/5518/10726119/a844dfce-7c0b-11e5-99c3-a818f3ef3dd2.png)
19
+ ![rucaptcha1](https://cloud.githubusercontent.com/assets/5518/10726119/a844dfce-7c0b-11e5-99c3-a818f3ef3dd2.png) ![rucaptcha2](https://cloud.githubusercontent.com/assets/5518/10747608/2f2f5f10-7c92-11e5-860b-914db5695a57.png) ![rucaptcha3](https://cloud.githubusercontent.com/assets/5518/10747609/2f5bbac4-7c92-11e5-8192-4aa5dfb025b7.png) ![rucaptcha4](https://cloud.githubusercontent.com/assets/5518/10747611/2f7c6a12-7c92-11e5-8730-de7295b36dd6.png) ![rucaptcha5](https://cloud.githubusercontent.com/assets/5518/10747610/2f7a9d86-7c92-11e5-911a-44596c9aeef5.png)
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/initializes/rucaptcha.rb`
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
@@ -1,3 +1,3 @@
1
1
  'zh-CN':
2
2
  rucaptcha:
3
- invalid: "驗證碼不正確"
3
+ invalid: "验证码不正确"
@@ -1,3 +1,3 @@
1
1
  'zh-TW':
2
2
  rucaptcha:
3
- invalid: "验证码不正确"
3
+ invalid: "驗證碼不正確"
data/lib/rucaptcha.rb CHANGED
@@ -1,4 +1,6 @@
1
- require 'active_support/core_ext'
1
+ require 'rails'
2
+ require 'action_controller'
3
+ require 'active_support/all'
2
4
  require_relative 'rucaptcha/version'
3
5
  require_relative 'rucaptcha/configuration'
4
6
  require_relative 'rucaptcha/controller_helpers'
@@ -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(9) + 1).to_s)
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
- right = params[:_rucaptcha].downcase.strip == session[:_rucaptcha]
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
@@ -1,3 +1,3 @@
1
1
  module RuCaptcha
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
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: 0.1.3
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-26 00:00:00.000000000 Z
11
+ date: 2015-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: posix-spawn