traptcha 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,9 +7,9 @@ module Traptcha
7
7
  end
8
8
 
9
9
  def valid_captcha?
10
- params[:captcha] && session[:captcha] && Traptcha::Captcha.new(params[:captcha]).value == session[:captcha]
10
+ params[:captcha] && params[:secure_hash] && Traptcha::Captcha.new(params[:captcha]).value == params[:secure_hash]
11
11
  end
12
-
12
+
13
13
  def validate_captcha
14
14
  raise Traptcha::InvalidCaptcha unless valid_captcha?
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module Traptcha
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
@@ -1,7 +1,11 @@
1
+ require 'base64'
2
+
1
3
  module Traptcha
2
4
  module ViewHelpers
3
5
  def captcha_image_tag
4
- tag :img, :src => "#{captcha_path}?#{rand}", :id => 'traptcha', :alt => 'captcha'
6
+ captcha = Traptcha::Captcha.generate
7
+
8
+ tag(:img, :src => "data:image/png;base64,#{Base64.encode64(captcha.to_png)}", :id => 'traptcha', :alt => 'captcha') + hidden_field_tag(:secure_hash, captcha.value)
5
9
  end
6
10
 
7
11
  def captcha_label_tag
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traptcha
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 12
10
- version: 0.0.12
9
+ - 13
10
+ version: 0.0.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rodrigo Navarro
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-14 00:00:00 -03:00
18
+ date: 2011-09-20 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency