simple_captcha_audio 0.0.1.rc1 → 0.0.1.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8b56e94e3539b08fa2a314cea078ebc02a8acdc
4
- data.tar.gz: 3448bfe4e1b00d213dc9b433d6794db46ac13a10
3
+ metadata.gz: f83bd3c57d4c0ffcbda38de5ba983d8245ad8a53
4
+ data.tar.gz: 7daa916dd1e552e521f3159561609f8bde6f05b4
5
5
  SHA512:
6
- metadata.gz: 18c3e8bd900c72c0ed24c66c9b3598adbbfb3fe031a5a2828b5d219aedf88102f0cfe7912876d1b067402e3f6bc4e49b8813369f54b69e9fb9cfbbc069db9d6d
7
- data.tar.gz: 640baacc3d6a11dc729e84daca026698440abb3dd7192a8cd05d9109f64cb7fd56b38b7257334ee3c0d7e3a29bf247ee891b5f9dec4a4948bcdc0e7b32711ebb
6
+ metadata.gz: 5039b9aa2d15f8732331f6f2d274eb612e192001988fa1e4408eba92963390fb62d09bda68a5c4a2af675f1f23ae0b597b053fb29a56c94e060a657166eacb84
7
+ data.tar.gz: e896145cc516ea8db7d7f47638bedfbe763bca6d5b6eddbffa631df876ca21428cd7598edf28e0896f0d169eb7d152fd265f749818a07166eaa53c87c5daef6f
@@ -35,5 +35,34 @@ module SimpleCaptcha
35
35
  [status, headers, body]
36
36
  end
37
37
  end
38
+
39
+ def refresh_code(env)
40
+ request = Rack::Request.new(env)
41
+
42
+ request.session.delete :captcha
43
+ key = simple_captcha_key(nil, request)
44
+ options = {}
45
+ options[:field_value] = set_simple_captcha_data(key, options)
46
+ url = simple_captcha_image_url(key, options)
47
+
48
+ status = 200
49
+ id = request.params['id']
50
+ captcha_hidden_field_id = simple_captch_hidden_field_id(id)
51
+
52
+ audio_id = generate_audio_id(id)
53
+ audio_url = simple_captcha_audio_url(key, options)
54
+
55
+ body = %Q{
56
+ $("##{id}").attr('src', '#{url}');
57
+ $("##{audio_id}").attr('src', '#{audio_url}')
58
+ $("##{ captcha_hidden_field_id }").attr('value', '#{key}');
59
+ }
60
+ headers = {'Content-Type' => 'text/javascript; charset=utf-8', "Content-Disposition" => "inline; filename='captcha.js'", "Content-Length" => body.length.to_s}.merge(SimpleCaptcha.extra_response_headers)
61
+ [status, headers, [body]]
62
+ end
63
+
64
+ def generate_audio_id(id)
65
+ id.gsub('simple_captcha', simple_captcha_id_prefix)
66
+ end
38
67
  end
39
68
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleCaptchaAudio
2
- VERSION = "0.0.1.rc1"
2
+ VERSION = "0.0.1.rc2"
3
3
  end
@@ -30,7 +30,11 @@ module SimpleCaptcha
30
30
  end
31
31
 
32
32
  def simple_captcha_audio_id(options={})
33
- "simple_captcha-audio-#{options[:field_value][0..10]}"
33
+ "#{ simple_captcha_id_prefix }-#{options[:field_value][0..10]}"
34
+ end
35
+
36
+ def simple_captcha_id_prefix
37
+ "simple_captcha-audio"
34
38
  end
35
39
  end
36
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_captcha_audio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.rc1
4
+ version: 0.0.1.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aditya Kapoor