diff --git a/config/diaspora.yml.example b/config/diaspora.yml.example index e3a8ecc9f..d9836626e 100644 --- a/config/diaspora.yml.example +++ b/config/diaspora.yml.example @@ -289,7 +289,7 @@ configuration: ## Section ## Captcha image size (default='120x20') #image_size: '120x20' - ## Length of captcha text (default=5) + ## Length of captcha text (default=5)(max=12) #captcha_length: 5 ## Captcha image style (default='simply_green') diff --git a/config/initializers/setup_simple_captcha.rb b/config/initializers/setup_simple_captcha.rb index 69ce517c4..d4b315234 100644 --- a/config/initializers/setup_simple_captcha.rb +++ b/config/initializers/setup_simple_captcha.rb @@ -1,7 +1,12 @@ SimpleCaptcha.setup do |sc| sc.image_size = AppConfig.settings.captcha.image_size - sc.length = AppConfig.settings.captcha.captcha_length.to_i + value_length = AppConfig.settings.captcha.captcha_length.to_i + if value_length <= 12 && value_length > 0 + sc.length = value_length + else + sc.length = 5 + end sc.image_style = AppConfig.settings.captcha.image_style sc.distortion = AppConfig.settings.captcha.distortion p AppConfig.settings.captcha -end \ No newline at end of file +end diff --git a/db/migrate/20140826165533_increase_simple_captcha_limit.rb b/db/migrate/20140826165533_increase_simple_captcha_limit.rb new file mode 100644 index 000000000..b4d43dd64 --- /dev/null +++ b/db/migrate/20140826165533_increase_simple_captcha_limit.rb @@ -0,0 +1,8 @@ +class IncreaseSimpleCaptchaLimit < ActiveRecord::Migration + def self.up + change_column :simple_captcha_data, :value, :string, :limit => 12 + end + def self.down + change_column :simple_captcha_data, :value, :string, :limit => 6 + end +end diff --git a/db/schema.rb b/db/schema.rb index 007a4077f..f8f12929b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140824230505) do +ActiveRecord::Schema.define(version: 20140826165533) do create_table "account_deletions", force: true do |t| t.string "diaspora_handle" @@ -449,7 +449,7 @@ ActiveRecord::Schema.define(version: 20140824230505) do create_table "simple_captcha_data", force: true do |t| t.string "key", limit: 40 - t.string "value", limit: 6 + t.string "value", limit: 12 t.datetime "created_at" t.datetime "updated_at" end