acts_as_textcaptcha 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
|
|
1
|
+
development: &non_production_settings
|
2
|
+
api_key: 8u5ixtdnq9csc84cok0owswgo
|
3
|
+
# bcrypt can be used to encrypt valid possible answers in your session; http://bcrypt-ruby.rubyforge.org/
|
4
|
+
# (recommended if you are using cookie session storage)
|
5
|
+
# NOTE: bcrypt_salt must be a valid bcrypt salt; for security PLEASE CHANGE THIS, open irb and enter; require 'bcrypt'; BCrypt::Engine.generate_salt
|
6
|
+
bcrypt_salt: $2a$10$j0bmycH.SVfD1b5mpEGPpe
|
7
|
+
# an optional logarithmic var which determines how computational expensive the hash is to calculate (a cost of 4 is twice as much work as a cost of 3)
|
8
|
+
bcrypt_cost: 10 # default is 10, must be > 4 (large number means slower encryption)
|
9
|
+
# if you'd rather NOT use bcrypt, just remove these two settings, bcrypt_salt and bcrypt_cost, valid possible answers will be MD5 digested in your session
|
10
|
+
questions:
|
11
|
+
- question: 'Is ice hot or cold?'
|
12
|
+
answers: 'cold'
|
13
|
+
- question: 'what color is an orange?'
|
14
|
+
answers: 'orange'
|
15
|
+
- question: 'what is two plus 3?'
|
16
|
+
answers: '5,five'
|
17
|
+
- question: 'what is 5 times two?'
|
18
|
+
answers: '10,ten'
|
19
|
+
- question: 'How many colors in the list, green, brown, foot and blue?'
|
20
|
+
answers: '3,three'
|
21
|
+
- question: 'what is Georges name?'
|
22
|
+
answers: 'george'
|
23
|
+
- question: '11 minus 1?'
|
24
|
+
answers: '10,ten'
|
25
|
+
- question: 'is boiling water hot or cold?'
|
26
|
+
answers: 'hot'
|
27
|
+
- question: 'what color is my blue shirt today?'
|
28
|
+
answers: 'blue'
|
29
|
+
- question: 'what is 16 plus 4?'
|
30
|
+
answers: '20,twenty'
|
31
|
+
|
32
|
+
test:
|
33
|
+
*non_production_settings
|
34
|
+
|
35
|
+
production:
|
36
|
+
*non_production_settings
|
@@ -15,6 +15,13 @@ rescue LoadError => e
|
|
15
15
|
end
|
16
16
|
|
17
17
|
module ActsAsTextcaptcha
|
18
|
+
|
19
|
+
class Railtie < ::Rails::Railtie
|
20
|
+
rake_tasks do
|
21
|
+
load "tasks/textcaptcha.rake"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
18
25
|
module Textcaptcha #:nodoc:
|
19
26
|
|
20
27
|
def acts_as_textcaptcha(options = nil)
|
@@ -45,9 +52,9 @@ module ActsAsTextcaptcha
|
|
45
52
|
# if returning false model.validate will always be false with errors on base
|
46
53
|
def allowed?; true end
|
47
54
|
|
48
|
-
def validate_textcaptcha
|
55
|
+
def validate_textcaptcha
|
49
56
|
# if not new_record? we dont spam check on existing records (ie. no spam check on updates/edits)
|
50
|
-
if !respond_to?('new_record?') || new_record?
|
57
|
+
if !respond_to?('new_record?') || new_record?
|
51
58
|
if allowed?
|
52
59
|
if possible_answers && perform_spam_check? && !validate_spam_answer
|
53
60
|
errors.add(:spam_answer, 'is incorrect, try another question instead')
|
@@ -0,0 +1,23 @@
|
|
1
|
+
namespace :textcaptcha do
|
2
|
+
desc "Adds a textcaptcha.yml template config file to ./config "
|
3
|
+
task :generate_config do
|
4
|
+
|
5
|
+
src = File.join(File.dirname(__FILE__), '../..', 'config', 'textcaptcha.yml')
|
6
|
+
dest = File.join(Rails.root, 'config', 'textcaptcha.yml')
|
7
|
+
if File.exist?(dest)
|
8
|
+
puts "\ntextcaptcha config file: #{dest}\n ... already exists. Aborting.\n\n"
|
9
|
+
else
|
10
|
+
config_file = ''
|
11
|
+
f = File.open(src, 'r')
|
12
|
+
f.each_line { |line| config_file += line }
|
13
|
+
config_file.gsub!(/api\_key\:(.+)$/, 'api_key: # get one at http://textcaptcha.com' )
|
14
|
+
config_file.gsub!(/bcrypt\_salt\:(.+)$/, "bcrypt_salt: #{BCrypt::Engine.generate_salt}" ) if defined?(BCrypt)
|
15
|
+
|
16
|
+
f = File.new(dest, 'w')
|
17
|
+
f.write(config_file)
|
18
|
+
f.close
|
19
|
+
puts "\ntextcaptcha.yml generated at #{dest} (with a new BCrypt salt).\nNOTE: edit this file and add your textcaptcha api key (from http://textcaptcha.com)"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_textcaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 2.1.
|
9
|
+
- 5
|
10
|
+
version: 2.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthew Hutchinson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-20 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -47,11 +47,13 @@ extra_rdoc_files:
|
|
47
47
|
- LICENSE
|
48
48
|
- README.rdoc
|
49
49
|
files:
|
50
|
+
- config/textcaptcha.yml
|
50
51
|
- lib/acts_as_textcaptcha.rb
|
51
52
|
- lib/acts_as_textcaptcha/framework/rails2.rb
|
52
53
|
- lib/acts_as_textcaptcha/framework/rails3.rb
|
53
54
|
- lib/acts_as_textcaptcha/textcaptcha.rb
|
54
55
|
- lib/acts_as_textcaptcha/textcaptcha_helper.rb
|
56
|
+
- lib/tasks/textcaptcha.rake
|
55
57
|
- LICENSE
|
56
58
|
- README.rdoc
|
57
59
|
- spec/acts_as_textcaptcha_spec.rb
|