summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-05 13:53:18 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-05 13:53:18 +0000
commit7c2490c6fc9230fdcea7b4ccdd82648a818a9bbf (patch)
treeaebe624a58ea6043e8de515eda09778c75e79541
parentd56f916a0e10dc389efc6a532fe7d25f4aec4acd (diff)
downloadredmine-7c2490c6fc9230fdcea7b4ccdd82648a818a9bbf.tar.gz
redmine-7c2490c6fc9230fdcea7b4ccdd82648a818a9bbf.zip
Login link unexpected logs you out (#12611).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11122 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/account_controller.rb4
-rw-r--r--test/functional/account_controller_test.rb8
2 files changed, 11 insertions, 1 deletions
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'