fake_password_field 1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 734c3c500012fc480a2624ea938f964c5c44e352
4
+ data.tar.gz: 969c471ad4ba7c80335d241afe1e8617558588ec
5
+ SHA512:
6
+ metadata.gz: 52afb04ca150187ebb90cf9fc31477d7cf0c59002821d1b4e105760cccec3070076611427f9cc170fa6bddcda25ee3eac279052358bb333653a417ee5399ec87
7
+ data.tar.gz: 51274595ab9d86eae600b4c0afe3528ca9235bd9e5d155d0a64a7c6762d6114440af8e6ea299fa51eaf6d33f68bccfaee457af3f4114f6e6d10f60eca169a810
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ ## FakePasswordField
2
+
3
+ Prevents Safari from autofilling password fields you don't want autofilled. See http://stackoverflow.com/questions/22817801/how-to-disable-auto-fill-in-safari-7 for a good explanation of the bug.
4
+
5
+ Tested on Rails 4 but probably works on older versions too.
6
+
7
+ ### Installing
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'fake_password_field'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fake_password_field
20
+
21
+ ### Usage
22
+
23
+ In your views, replace `password_field_tag` with `fake_password_field_tag`. Or if you're using a FormBuilder (`form_for(@object)...`), replace `f.password_field` with `f.fake_password_field`.
24
+
25
+ Everything else should work the same - please file an issue if it's not working!
26
+
27
+ ### How it works
28
+
29
+ The gem will render a text field (`<input type=text>`) with the same markup as your password field. Directly below, it inserts a snippet of Javascript that will convert this text field to a password field after the page has loaded and Safari's autofiller has finished running.
30
+
31
+ The snippet looks like this:
32
+
33
+ ````javascript
34
+ <script>
35
+ // http://stackoverflow.com/q/22817801/641293
36
+ var i = document.getElementByTagName('input'), e = i[i.length - 1]
37
+ setTimeout(function() { e.type = 'password' }, 500)
38
+ </script>
39
+ ````
40
+
41
+ ### Shortfalls
42
+
43
+ If you have a default value in the password field, that value will flash briefly before being replaced by the password field dots. Generally it's not considered a good practice to include the user's password (or indeed, any password) in your HTML. But if you really need to, you should try one of the other workarounds suggested at http://stackoverflow.com/questions/22817801/how-to-disable-auto-fill-in-safari-7 or elsewhere, instead of this gem.
@@ -0,0 +1,2 @@
1
+ require 'fake_password_field/helpers'
2
+ require 'fake_password_field/version'
@@ -0,0 +1,35 @@
1
+ module ActionView
2
+ module Helpers
3
+ class FormBuilder
4
+ def fake_password_field(method, options = {})
5
+ text_field_output = text_field(method, options)
6
+ javascript = <<-STR
7
+ <script>
8
+ // http://stackoverflow.com/q/22817801/641293
9
+ var i = document.getElementByTagName('input'), e = i[i.length - 1]
10
+ setTimeout(function() { e.type = 'password' }, 500)
11
+ </script>
12
+ STR
13
+ "#{text_field_output} #{javascript}".html_safe
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ module ActionView
20
+ module Helpers
21
+ module FormTagHelper
22
+ def fake_password_field_tag(name = "password", value = nil, options = {})
23
+ text_field_output = text_field_tag(name, value, options)
24
+ javascript = <<-STR
25
+ <script>
26
+ // http://stackoverflow.com/q/22817801/641293
27
+ var i = document.getElementByTagName('input'), e = i[i.length - 1]
28
+ setTimeout(function() { e.type = 'password' }, 500)
29
+ </script>
30
+ STR
31
+ "#{text_field_output} #{javascript}".html_safe
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module FakePasswordField
2
+ VERSION = 1
3
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fake_password_field
3
+ version: !ruby/object:Gem::Version
4
+ version: '1'
5
+ platform: ruby
6
+ authors:
7
+ - Alex Ghiculescu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionview
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ description: Fix autofilling password fields in Safari. Replace password_field_tag
28
+ with fake_password_field_tag, or f.password_field with f.fake_password_field.
29
+ email: alexghiculescu@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - README.md
35
+ - lib/fake_password_field.rb
36
+ - lib/fake_password_field/helpers.rb
37
+ - lib/fake_password_field/version.rb
38
+ homepage: http://rubygems.org/gems/fake_password_field
39
+ licenses: []
40
+ metadata: {}
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 2.2.0.rc.1
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: fake_password_field
61
+ test_files: []
62
+ has_rdoc: