From 4f761e34e89cad617441abee78eb03bd1d935169 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sun, 8 Dec 2024 06:40:47 +0000 Subject: Enable browser autocomplete for login input fields (#41937). Contributed by Thomas Butz (user:otbutz). git-svn-id: https://svn.redmine.org/redmine/trunk@23361 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/account/login.html.erb | 4 ++-- app/views/account/password_recovery.html.erb | 4 ++-- app/views/my/password.html.erb | 6 +++--- app/views/sudo_mode/_new_modal.html.erb | 2 +- app/views/sudo_mode/new.html.erb | 2 +- test/functional/account_controller_test.rb | 4 ++-- test/functional/my_controller_test.rb | 6 +++--- test/integration/account_test.rb | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 27878bc7e..fb8085d71 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -5,13 +5,13 @@ <%= back_url_hidden_field_tag %> - <%= text_field_tag 'username', params[:username], :tabindex => '1', :autofocus => params[:username].blank? %> + <%= text_field_tag 'username', params[:username], :tabindex => '1', :autocomplete => 'username', :autofocus => params[:username].blank? %> - <%= password_field_tag 'password', nil, :tabindex => '2', :autofocus => params[:username].present? %> + <%= password_field_tag 'password', nil, :tabindex => '2', :autocomplete => 'current-password', :autofocus => params[:username].present? %> <% if Setting.autologin? %> diff --git a/app/views/account/password_recovery.html.erb b/app/views/account/password_recovery.html.erb index 0c275b476..a3556ce75 100644 --- a/app/views/account/password_recovery.html.erb +++ b/app/views/account/password_recovery.html.erb @@ -7,7 +7,7 @@

- <%= password_field_tag 'new_password', nil, :size => 25 %> + <%= password_field_tag 'new_password', nil, :size => 25, :autocomplete => 'new-password' %> <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %> <% if Setting.password_required_char_classes.any? %> <%= l(:text_characters_must_contain, :character_classes => Setting.password_required_char_classes.collect{|c| l("label_password_char_class_#{c}")}.join(", ")) %> @@ -16,7 +16,7 @@

- <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %> + <%= password_field_tag 'new_password_confirmation', nil, :size => 25, :autocomplete => 'new-password' %>

<%= submit_tag l(:button_save) %>

diff --git a/app/views/my/password.html.erb b/app/views/my/password.html.erb index 91f66ccd7..ad17de4c6 100644 --- a/app/views/my/password.html.erb +++ b/app/views/my/password.html.erb @@ -5,10 +5,10 @@ <%= form_tag({}, :class => "tabular") do %>

-<%= password_field_tag 'password', nil, :size => 25 %>

+<%= password_field_tag 'password', nil, :size => 25, :autocomplete => 'current-password' %>

-<%= password_field_tag 'new_password', nil, :size => 25 %> +<%= password_field_tag 'new_password', nil, :size => 25, :autocomplete => 'new-password' %> <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %> <% if Setting.password_required_char_classes.any? %> <%= l(:text_characters_must_contain, :character_classes => Setting.password_required_char_classes.collect{|c| l("label_password_char_class_#{c}")}.join(", ")) %> @@ -16,7 +16,7 @@

-<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %>

+<%= password_field_tag 'new_password_confirmation', nil, :size => 25, :autocomplete => 'new-password' %>

<%= submit_tag l(:button_apply) %> <% end %> diff --git a/app/views/sudo_mode/_new_modal.html.erb b/app/views/sudo_mode/_new_modal.html.erb index 8c86436cf..d259c5a2a 100644 --- a/app/views/sudo_mode/_new_modal.html.erb +++ b/app/views/sudo_mode/_new_modal.html.erb @@ -8,7 +8,7 @@

- <%= password_field_tag :sudo_password, nil, size: 25 %> + <%= password_field_tag :sudo_password, nil, size: 25, :autocomplete => 'current-password' %>
<%= link_to l(:label_password_lost), lost_password_path, :class => "lost_password" if Setting.lost_password? %>

diff --git a/app/views/sudo_mode/new.html.erb b/app/views/sudo_mode/new.html.erb index cd25ea1d6..6bf87cc8d 100644 --- a/app/views/sudo_mode/new.html.erb +++ b/app/views/sudo_mode/new.html.erb @@ -8,7 +8,7 @@

- <%= password_field_tag :sudo_password, nil, size: 25, autofocus: true %> + <%= password_field_tag :sudo_password, nil, size: 25, :autocomplete => 'current-password', autofocus: true %>
<%= link_to l(:label_password_lost), lost_password_path, :class => "lost_password" if Setting.lost_password? %>

diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 083b2bafd..4954f3292 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -30,8 +30,8 @@ class AccountControllerTest < Redmine::ControllerTest get :login assert_response :success - assert_select 'input[name=username]' - assert_select 'input[name=password]' + assert_select 'input[name=username][autocomplete=username]' + assert_select 'input[name=password][autocomplete=current-password]' end def test_get_login_while_logged_in_should_redirect_to_back_url_if_present diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb index b485b5c9a..b311854f1 100644 --- a/test/functional/my_controller_test.rb +++ b/test/functional/my_controller_test.rb @@ -605,9 +605,9 @@ class MyControllerTest < Redmine::ControllerTest def test_change_password get :password assert_response :success - assert_select 'input[type=password][name=password]' - assert_select 'input[type=password][name=new_password]' - assert_select 'input[type=password][name=new_password_confirmation]' + assert_select 'input[type=password][name=password][autocomplete=current-password]' + assert_select 'input[type=password][name=new_password][autocomplete=new-password]' + assert_select 'input[type=password][name=new_password_confirmation][autocomplete=new-password]' end def test_update_password diff --git a/test/integration/account_test.rb b/test/integration/account_test.rb index 1953588b6..e40584152 100644 --- a/test/integration/account_test.rb +++ b/test/integration/account_test.rb @@ -136,8 +136,8 @@ class AccountTest < Redmine::IntegrationTest follow_redirect! assert_response :success assert_select 'input[type=hidden][name=token][value=?]', token.value - assert_select 'input[name=new_password]' - assert_select 'input[name=new_password_confirmation]' + assert_select 'input[name=new_password][autocomplete=new-password]' + assert_select 'input[name=new_password_confirmation][autocomplete=new-password]' post( "/account/lost_password", -- cgit v1.2.3