blogs_captcha 0.0.9 → 0.1.0
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/lib/blogs_captcha.rb +0 -4
- data/lib/blogs_captcha/controller_helpers.rb +9 -6
- data/lib/blogs_captcha/engine.rb +2 -2
- data/lib/blogs_captcha/version.rb +1 -1
- metadata +1 -2
- data/lib/blogs_captcha/view_helpers.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75ab1e4366bcb63bb8847aaf62146d3c7496e70f3ef77aa7b8ad3ba320ebc328
|
4
|
+
data.tar.gz: 980589fceebec43878277bd5fe3c095d623cf6337d17befda94e1c808a9f7eaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b44e1f635f0ca58f9ab0ff3902612cff76f96b684f34cf04eb8c8ac2ce64b92e4f6ebefeb816926061b59550b9f869b4d38b1d2c116792d2913b299fe7562a57
|
7
|
+
data.tar.gz: 3b146013052d3566e281455f7beeda551714afa3f7bfee94e9eb6dd24048d0f2d338943d6a2a62695f312ade9f34e130860079636e731f8deba3eb1f108dbc1f
|
data/lib/blogs_captcha.rb
CHANGED
@@ -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
|
-
|
21
|
-
|
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 = {})
|
data/lib/blogs_captcha/engine.rb
CHANGED
@@ -2,11 +2,11 @@ module BlogsCaptcha
|
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace BlogsCaptcha
|
4
4
|
|
5
|
-
initializer '
|
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 => '/
|
9
|
+
mount BlogsCaptcha::Engine => '/captcha'
|
10
10
|
end
|
11
11
|
|
12
12
|
BlogsCaptcha.check_cache_store! unless BlogsCaptcha.config.skip_cache_store_check
|
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
|
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
|