##// END OF EJS Templates
Preserve username when authentification failed (#11846)....
Jean-Philippe Lang -
r10398:3e706adddddf
parent child
Show More
@@ -5,7 +5,7
5 <table>
5 <table>
6 <tr>
6 <tr>
7 <td align="right"><label for="username"><%=l(:field_login)%>:</label></td>
7 <td align="right"><label for="username"><%=l(:field_login)%>:</label></td>
8 <td align="left"><%= text_field_tag 'username', nil, :tabindex => '1' %></td>
8 <td align="left"><%= text_field_tag 'username', params[:username], :tabindex => '1' %></td>
9 </tr>
9 </tr>
10 <tr>
10 <tr>
11 <td align="right"><label for="password"><%=l(:field_password)%>:</label></td>
11 <td align="right"><label for="password"><%=l(:field_password)%>:</label></td>
@@ -36,7 +36,12
36 </td>
36 </td>
37 </tr>
37 </tr>
38 </table>
38 </table>
39 <%= javascript_tag "$('#username').focus();" %>
40 <% end %>
39 <% end %>
41 </div>
40 </div>
42 <%= call_hook :view_account_login_bottom %>
41 <%= call_hook :view_account_login_bottom %>
42
43 <% if params[:username].present? %>
44 <%= javascript_tag "$('#password').focus();" %>
45 <% else %>
46 <%= javascript_tag "$('#username').focus();" %>
47 <% end %>
@@ -31,6 +31,15 class AccountControllerTest < ActionController::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_get_login
35 get :login
36 assert_response :success
37 assert_template 'login'
38
39 assert_select 'input[name=username]'
40 assert_select 'input[name=password]'
41 end
42
34 def test_login_should_redirect_to_back_url_param
43 def test_login_should_redirect_to_back_url_param
35 # request.uri is "test.host" in test environment
44 # request.uri is "test.host" in test environment
36 post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http://test.host/issues/show/1'
45 post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http://test.host/issues/show/1'
@@ -46,9 +55,11 class AccountControllerTest < ActionController::TestCase
46 post :login, :username => 'admin', :password => 'bad'
55 post :login, :username => 'admin', :password => 'bad'
47 assert_response :success
56 assert_response :success
48 assert_template 'login'
57 assert_template 'login'
49 assert_tag 'div',
58
50 :attributes => { :class => "flash error" },
59 assert_select 'div.flash.error', :text => /Invalid user or password/
51 :content => /Invalid user or password/
60 assert_select 'input[name=username][value=admin]'
61 assert_select 'input[name=password]'
62 assert_select 'input[name=password][value]', 0
52 end
63 end
53
64
54 def test_login_should_rescue_auth_source_exception
65 def test_login_should_rescue_auth_source_exception
General Comments 0
You need to be logged in to leave comments. Login now