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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f83bd3c57d4c0ffcbda38de5ba983d8245ad8a53
|
4
|
+
data.tar.gz: 7daa916dd1e552e521f3159561609f8bde6f05b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -30,7 +30,11 @@ module SimpleCaptcha
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def simple_captcha_audio_id(options={})
|
33
|
-
"
|
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
|