blogs_captcha 0.0.9 → 0.1.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
  SHA256:
3
- metadata.gz: 9f0b4dd4a0072f9d9315a6a9983ddd22d7e5b0375c86516fb419cdebe2a09cec
4
- data.tar.gz: a995c2e8153116a9c8c0ac5ed1e3b208effe54abbccbc3375108a301607a805b
3
+ metadata.gz: 75ab1e4366bcb63bb8847aaf62146d3c7496e70f3ef77aa7b8ad3ba320ebc328
4
+ data.tar.gz: 980589fceebec43878277bd5fe3c095d623cf6337d17befda94e1c808a9f7eaf
5
5
  SHA512:
6
- metadata.gz: 1199dbb834cabcfad6b417a12eb46afbec7ae4ff91cc331c89f7c141f11f6ed8c3ce2655653b5a66a29efcdb582700232f379939e0fa51f70bc54cb18870149f
7
- data.tar.gz: 17487da4a21a88573a0443f91862fe5c20dcfa8b68d89f643f796e6e78a5682d76044da936fea59223e9fde580c329ff46f6dbdd2bce197304d2bc9f1494b9cd
6
+ metadata.gz: b44e1f635f0ca58f9ab0ff3902612cff76f96b684f34cf04eb8c8ac2ce64b92e4f6ebefeb816926061b59550b9f869b4d38b1d2c116792d2913b299fe7562a57
7
+ data.tar.gz: 3b146013052d3566e281455f7beeda551714afa3f7bfee94e9eb6dd24048d0f2d338943d6a2a62695f312ade9f34e130860079636e731f8deba3eb1f108dbc1f
data/lib/blogs_captcha.rb CHANGED
@@ -74,7 +74,3 @@ end
74
74
  ActiveSupport.on_load(:action_controller) do
75
75
  ActionController::Base.send :include, BlogsCaptcha::ControllerHelpers
76
76
  end
77
-
78
- ActiveSupport.on_load(:action_view) do
79
- include BlogsCaptcha::ViewHelpers
80
- end
@@ -6,19 +6,22 @@ module BlogsCaptcha
6
6
  helper_method :verify_captcha?
7
7
  end
8
8
 
9
- def captcha_sesion_key_key
10
- ['captcha-session', 'test'].join(':')
11
- end
12
-
13
9
  # Generate a new Captcha
14
10
  def generate_captcha
15
11
  res = BlogsCaptcha.generate()
12
+ key = SecureRandom.uuid
13
+
16
14
  session_val = {
17
15
  code: res[0],
18
16
  time: Time.now.to_i
19
17
  }
20
- BlogsCaptcha.cache.write(captcha_sesion_key_key, session_val, expires_in: BlogsCaptcha.config.expires_in)
21
- res[1]
18
+
19
+ BlogsCaptcha.cache.write(['captcha-session', key].join(':'), session_val, expires_in: BlogsCaptcha.config.expires_in)
20
+
21
+ {
22
+ data: res[1],
23
+ key: key,
24
+ }
22
25
  end
23
26
 
24
27
  def verify_captcha?(resource = nil, opts = {})
@@ -2,11 +2,11 @@ module BlogsCaptcha
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace BlogsCaptcha
4
4
 
5
- initializer 'rucaptcha.init' do |app|
5
+ initializer 'blogs_captcha.init' do |app|
6
6
  # https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/action_dispatch/routing/route_set.rb#L268
7
7
  # `app.routes.prepend` start from Rails 3.2 - 5.0
8
8
  app.routes.prepend do
9
- mount BlogsCaptcha::Engine => '/rucaptcha'
9
+ mount BlogsCaptcha::Engine => '/captcha'
10
10
  end
11
11
 
12
12
  BlogsCaptcha.check_cache_store! unless BlogsCaptcha.config.skip_cache_store_check
@@ -1,3 +1,3 @@
1
1
  module BlogsCaptcha
2
- VERSION = '0.0.9'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blogs_captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ChinaHDJ
@@ -56,7 +56,6 @@ files:
56
56
  - lib/blogs_captcha/engine.rb
57
57
  - lib/blogs_captcha/errors/configuration.rb
58
58
  - lib/blogs_captcha/version.rb
59
- - lib/blogs_captcha/view_helpers.rb
60
59
  homepage:
61
60
  licenses:
62
61
  - MIT
@@ -1,19 +0,0 @@
1
- module BlogsCaptcha
2
- module ViewHelpers
3
- def rucaptcha_input_tag(opts = {})
4
- opts[:name] = '_rucaptcha'
5
- opts[:type] = 'text'
6
- opts[:autocorrect] = 'off'
7
- opts[:autocapitalize] = 'off'
8
- opts[:pattern] = '[a-zA-Z]*'
9
- opts[:autocomplete] = 'off'
10
- opts[:maxlength] ||= 5
11
- tag(:input, opts)
12
- end
13
-
14
- def rucaptcha_image_tag(opts = {})
15
- opts[:class] = opts[:class] || 'rucaptcha-image'
16
- image_tag(ru_captcha.root_path, opts)
17
- end
18
- end
19
- end