Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/simple_captcha/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def simple_captcha_valid?
return true if Rails.env.test?

if params[:captcha]
data = SimpleCaptcha::Utils::simple_captcha_value(session[:captcha])
data = SimpleCaptcha::Utils::simple_captcha_value(params[:captcha_key] || session[:captcha])
result = data == params[:captcha].delete(" ").upcase
SimpleCaptcha::Utils::simple_captcha_passed!(session[:captcha]) if result
return result
Expand Down
4 changes: 2 additions & 2 deletions lib/simple_captcha/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ def generate_simple_captcha_image(simple_captcha_key) #:nodoc
params = ImageHelpers.image_params(SimpleCaptcha.image_style).dup
params << "-size #{SimpleCaptcha.image_size}"
params << "-wave #{amplitude}x#{frequency}"
params << "-gravity 'Center'"
params << "-gravity Center"
params << "-pointsize 22"
params << "-implode 0.2"

dst = Tempfile.new(RUBY_VERSION < '1.9' ? 'simple_captcha.jpg' : ['simple_captcha', '.jpg'], SimpleCaptcha.tmp_path)
dst.binmode

params << "label:#{text} '#{File.expand_path(dst.path)}'"
params << "label:#{text} #{File.expand_path(dst.path)}"

SimpleCaptcha::Utils::run("convert", params.join(' '))

Expand Down
3 changes: 2 additions & 1 deletion lib/simple_captcha/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def simple_captcha_field(options={})
text_field(options[:object], :captcha, :value => '', :autocomplete => 'off') +
hidden_field(options[:object], :captcha_key, {:value => options[:field_value]})
else
text_field_tag(:captcha, nil, :autocomplete => 'off')
text_field_tag(:captcha, nil, :autocomplete => 'off') +
hidden_field_tag(:captcha_key, options[:field_value])
end
end

Expand Down