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
This commit is contained in:
Gustavo Bazan 2018-04-04 15:46:34 +01:00 committed by Leonardo Tegon
parent 45481df14a
commit 6260c29a86
5 changed files with 12 additions and 8 deletions

View File

@ -1,5 +1,9 @@
### Unreleased ### Unreleased
* enhancements
* Add `autocomplete="new-password"` to new password fields (by @gssbzn)
* Add `autocomplete="current-password"` to current password fields (by @gssbzn)
### 4.4.3 - 2018-03-17 ### 4.4.3 - 2018-03-17
* bug fixes * bug fixes
@ -44,7 +48,7 @@
* Validations were being ignored on singup in the `Trackable#update_tracked_fields!` method. (by @AshleyFoster) * Validations were being ignored on singup in the `Trackable#update_tracked_fields!` method. (by @AshleyFoster)
* Do not modify options for `#serializable_hash`. (by @guigs) * Do not modify options for `#serializable_hash`. (by @guigs)
* 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) * 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)
### 4.3.0 - 2017-05-14 ### 4.3.0 - 2017-05-14
* Enhancements * Enhancements

View File

@ -9,7 +9,7 @@
<% if @minimum_password_length %> <% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br /> <em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %> <% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "off" %> <%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
</div> </div>
<div class="field"> <div class="field">

View File

@ -14,7 +14,7 @@
<div class="field"> <div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br /> <%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "off" %> <%= f.password_field :password, autocomplete: "new-password" %>
<% if @minimum_password_length %> <% if @minimum_password_length %>
<br /> <br />
<em><%= @minimum_password_length %> characters minimum</em> <em><%= @minimum_password_length %> characters minimum</em>
@ -23,12 +23,12 @@
<div class="field"> <div class="field">
<%= f.label :password_confirmation %><br /> <%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %> <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div> </div>
<div class="field"> <div class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br /> <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "off" %> <%= f.password_field :current_password, autocomplete: "current-password" %>
</div> </div>
<div class="actions"> <div class="actions">

View File

@ -13,12 +13,12 @@
<% if @minimum_password_length %> <% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em> <em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br /> <% end %><br />
<%= f.password_field :password, autocomplete: "off" %> <%= f.password_field :password, autocomplete: "new-password" %>
</div> </div>
<div class="field"> <div class="field">
<%= f.label :password_confirmation %><br /> <%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %> <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div> </div>
<div class="actions"> <div class="actions">

View File

@ -8,7 +8,7 @@
<div class="field"> <div class="field">
<%= f.label :password %><br /> <%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %> <%= f.password_field :password, autocomplete: "current-password" %>
</div> </div>
<% if devise_mapping.rememberable? -%> <% if devise_mapping.rememberable? -%>