From: Jean-Philippe Lang Date: Sat, 5 Jan 2013 13:53:18 +0000 (+0000) Subject: Login link unexpected logs you out (#12611). X-Git-Tag: 2.3.0~347 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7c2490c6fc9230fdcea7b4ccdd82648a818a9bbf;p=redmine.git Login link unexpected logs you out (#12611). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11122 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index c8d27d33f..930d14236 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -25,7 +25,9 @@ class AccountController < ApplicationController # Login request and validation def login if request.get? - logout_user + if User.current.logged? + redirect_to home_url + end else authenticate_user end diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 32b9a564b..52b1235ab 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -33,6 +33,14 @@ class AccountControllerTest < ActionController::TestCase assert_select 'input[name=password]' end + def test_get_login_while_logged_in_should_redirect_to_home + @request.session[:user_id] = 2 + + get :login + assert_redirected_to '/' + assert_equal 2, @request.session[:user_id] + end + def test_login_should_redirect_to_back_url_param # request.uri is "test.host" in test environment post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http://test.host/issues/show/1'