Skip to content

Commit 6260c29

Browse files
Gustavo Bazantegon
authored andcommitted
Improve passwords autocomplete
Use `autocomplete="new-password"` or `autocomplete="current-password"` to better signal to browsers and password managers how to handle the password fields. This feature is especially useful for “change your password” and “new user” forms
1 parent 45481df commit 6260c29

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
### Unreleased
22

3+
* enhancements
4+
* Add `autocomplete="new-password"` to new password fields (by @gssbzn)
5+
* Add `autocomplete="current-password"` to current password fields (by @gssbzn)
6+
37
### 4.4.3 - 2018-03-17
48

59
* bug fixes
@@ -44,7 +48,7 @@
4448
* Validations were being ignored on singup in the `Trackable#update_tracked_fields!` method. (by @AshleyFoster)
4549
* Do not modify options for `#serializable_hash`. (by @guigs)
4650
* Email confirmations were being sent on sign in/sign out for application using `mongoid` and `mongoid-paperclip` gems. This is because previously we were checking if a model is from Active Record by checking if the method `after_commit` was defined - since `mongoid` doesn' have one - but `mongoid-paperclip` gem does define one, which cause this issue. (by @fjg)
47-
51+
4852
### 4.3.0 - 2017-05-14
4953

5054
* Enhancements

app/views/devise/passwords/edit.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<% if @minimum_password_length %>
1010
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
1111
<% end %>
12-
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
12+
<%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
1313
</div>
1414

1515
<div class="field">

app/views/devise/registrations/edit.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<div class="field">
1616
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
17-
<%= f.password_field :password, autocomplete: "off" %>
17+
<%= f.password_field :password, autocomplete: "new-password" %>
1818
<% if @minimum_password_length %>
1919
<br />
2020
<em><%= @minimum_password_length %> characters minimum</em>
@@ -23,12 +23,12 @@
2323

2424
<div class="field">
2525
<%= f.label :password_confirmation %><br />
26-
<%= f.password_field :password_confirmation, autocomplete: "off" %>
26+
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
2727
</div>
2828

2929
<div class="field">
3030
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
31-
<%= f.password_field :current_password, autocomplete: "off" %>
31+
<%= f.password_field :current_password, autocomplete: "current-password" %>
3232
</div>
3333

3434
<div class="actions">

app/views/devise/registrations/new.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
<% if @minimum_password_length %>
1414
<em>(<%= @minimum_password_length %> characters minimum)</em>
1515
<% end %><br />
16-
<%= f.password_field :password, autocomplete: "off" %>
16+
<%= f.password_field :password, autocomplete: "new-password" %>
1717
</div>
1818

1919
<div class="field">
2020
<%= f.label :password_confirmation %><br />
21-
<%= f.password_field :password_confirmation, autocomplete: "off" %>
21+
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
2222
</div>
2323

2424
<div class="actions">

app/views/devise/sessions/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<div class="field">
1010
<%= f.label :password %><br />
11-
<%= f.password_field :password, autocomplete: "off" %>
11+
<%= f.password_field :password, autocomplete: "current-password" %>
1212
</div>
1313

1414
<% if devise_mapping.rememberable? -%>

0 commit comments

Comments
 (0)