diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 9d570a9a..514e9923 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -20,9 +20,9 @@ class AccountController < ApplicationController # Login request and validation def login - if request.get? - logout_user - else + if User.current.logged? + redirect_to home_url + elsif request.post? authenticate_user end end diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 6c3ab70d..4ee25b14 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -47,6 +47,17 @@ class AccountControllerTest < ActionController::TestCase :content => /Invalid user or password/ end + def test_login + get :login + assert_template 'login' + end + + def test_login_with_logged_account + @request.session[:user_id] = 2 + get :login + assert_redirected_to home_url + end + if Object.const_defined?(:OpenID) def test_login_with_openid_for_existing_user