fake_password_field 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -15
- data/lib/fake_password_field/helpers.rb +8 -18
- data/lib/fake_password_field/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f0e7ed13d10911f2f14a31138b793471ae163df
|
4
|
+
data.tar.gz: 8583916fb7ae6cf62acb051b24c809573ec00a69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b96fa92fcbf425d42e16a9cdfb49f39570a116b5ea1caf11b19736acf097744247bce792ad4214a2dd480bba943909440ece2e3239f163fbff17fa69c9b9f6b0
|
7
|
+
data.tar.gz: dd0fc7d8598c60cdf8a799fbce4cd1839df5b3b075a849f2db0856fbfbb798aeca38a9b6a86768b700ff358aad65d1aa936104d1607e7efe505b0d215e003bc1
|
data/README.md
CHANGED
@@ -22,24 +22,16 @@ Available on RubyGems: https://rubygems.org/gems/fake_password_field
|
|
22
22
|
|
23
23
|
### Usage
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
All other parameters should be the same - you shouldn't need to change anything else in your view code. Please create an issue if that isn't the case.
|
25
|
+
Add a `fake_password_field_tag` to the top of your page. Or if you're using a FormBuilder (`form_for(@object)...`), add a `f.fake_password_field`.
|
28
26
|
|
29
27
|
### How it works
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
The snippet looks like this:
|
29
|
+
This inserts a dummy HTML password element, which is hidden from view and will not be posted. But it will trick Safari into not autofilling your actual password field.
|
34
30
|
|
35
|
-
|
36
|
-
<script>
|
37
|
-
// http://stackoverflow.com/q/22817801/641293
|
38
|
-
var i = document.getElementsByTagName('input'), e = i[i.length - 1]
|
39
|
-
setTimeout(function() { e.type = 'password' }, 500)
|
40
|
-
</script>
|
41
|
-
````
|
31
|
+
You should experiment with the best place in the form to add this element. Usually adding it to the top works well, but some form layouts work best if it's added to the bottom.
|
42
32
|
|
43
|
-
|
33
|
+
The HTML looks like this:
|
44
34
|
|
45
|
-
|
35
|
+
````html
|
36
|
+
<div class="break_safari_autofill" style="left: -9999px; position: fixed; width: 1px;"><input type="password"></div> <!-- http://stackoverflow.com/a/24471266/641293 -->
|
37
|
+
````
|
@@ -1,16 +1,11 @@
|
|
1
1
|
module ActionView
|
2
2
|
module Helpers
|
3
3
|
class FormBuilder
|
4
|
-
def fake_password_field
|
5
|
-
|
6
|
-
|
7
|
-
<script>
|
8
|
-
// http://stackoverflow.com/q/22817801/641293
|
9
|
-
var i = document.getElementsByTagName('input'), e = i[i.length - 1]
|
10
|
-
setTimeout(function() { e.type = 'password' }, 500)
|
11
|
-
</script>
|
4
|
+
def fake_password_field
|
5
|
+
html = <<-STR
|
6
|
+
<div class="break_safari_autofill" style="left: -9999px; position: fixed; width: 1px;"><input type="password"></div> <!-- http://stackoverflow.com/a/24471266/641293 -->
|
12
7
|
STR
|
13
|
-
|
8
|
+
html.html_safe
|
14
9
|
end
|
15
10
|
end
|
16
11
|
end
|
@@ -19,16 +14,11 @@ end
|
|
19
14
|
module ActionView
|
20
15
|
module Helpers
|
21
16
|
module FormTagHelper
|
22
|
-
def fake_password_field_tag
|
23
|
-
|
24
|
-
|
25
|
-
<script>
|
26
|
-
// http://stackoverflow.com/q/22817801/641293
|
27
|
-
var i = document.getElementsByTagName('input'), e = i[i.length - 1]
|
28
|
-
setTimeout(function() { e.type = 'password' }, 500)
|
29
|
-
</script>
|
17
|
+
def fake_password_field_tag
|
18
|
+
html = <<-STR
|
19
|
+
<div class="break_safari_autofill" style="left: -9999px; position: fixed; width: 1px;"><input type="password"></div> <!-- http://stackoverflow.com/a/24471266/641293 -->
|
30
20
|
STR
|
31
|
-
|
21
|
+
html.html_safe
|
32
22
|
end
|
33
23
|
end
|
34
24
|
end
|