self.logged_user = nil
else
# Authenticate user
- user = User.try_to_login(params[:login], params[:password])
+ user = User.try_to_login(params[:username], params[:password])
if user
self.logged_user = user
# generate a key and set cookie if autologin
<% form_tag({:action=> "login"}) do %>
<table>
<tr>
- <td align="right"><label for="login"><%=l(:field_login)%>:</label></td>
- <td align="left"><p><%= text_field_tag 'login', nil, :size => 40 %></p></td>
+ <td align="right"><label for="username"><%=l(:field_login)%>:</label></td>
+ <td align="left"><p><%= text_field_tag 'username', nil, :size => 40 %></p></td>
</tr>
<tr>
<td align="right"><label for="password"><%=l(:field_password)%>:</label></td>
</td>
</tr>
</table>
-<%= javascript_tag "Form.Element.focus('login');" %>
+<%= javascript_tag "Form.Element.focus('username');" %>
<% end %>
</div>
end
def test_login_with_wrong_password
- post :login, :login => 'admin', :password => 'bad'
+ post :login, :username => 'admin', :password => 'bad'
assert_response :success
assert_template 'login'
assert_tag 'div',
def test_autologin
Setting.autologin = "7"
Token.delete_all
- post :login, :login => 'admin', :password => 'admin', :autologin => 1
+ post :login, :username => 'admin', :password => 'admin', :autologin => 1
assert_redirected_to 'my/page'
token = Token.find :first
assert_not_nil token
assert_equal nil, session[:user_id]
assert_response :success
assert_template "account/login"
- post "/account/login", :login => login, :password => password
+ post "/account/login", :username => login, :password => password
assert_redirected_to "my/page"
assert_equal login, User.find(session[:user_id]).login
end