]> source.dussan.org Git - redmine.git/commitdiff
Login link unexpected logs you out (#12611).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 5 Jan 2013 13:53:18 +0000 (13:53 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 5 Jan 2013 13:53:18 +0000 (13:53 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11122 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/account_controller.rb
test/functional/account_controller_test.rb

index c8d27d33fd4b407c675c73c0bfe2fee1ca31ece9..930d142360401372d9529de8afc6661859695774 100644 (file)
@@ -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
index 32b9a564bddf773328dc557edf0db563d763b4eb..52b1235ab8b02e53e70f81545ca0adac6f2b8464 100644 (file)
@@ -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'