1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-19 15:01:14 +00:00

Set a back_url when forcing new login after session expiration (#19655).

Patch by Holger Just.

git-svn-id: http://svn.redmine.org/redmine/trunk@14245 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2015-05-09 10:43:09 +00:00
parent f2b4bd5005
commit ef2e75f072
2 changed files with 7 additions and 7 deletions

View File

@ -63,9 +63,9 @@ class ApplicationController < ActionController::Base
if session[:user_id] if session[:user_id]
if session_expired? && !try_to_autologin if session_expired? && !try_to_autologin
set_localization(User.active.find_by_id(session[:user_id])) set_localization(User.active.find_by_id(session[:user_id]))
reset_session self.logged_user = nil
flash[:error] = l(:error_session_expired) flash[:error] = l(:error_session_expired)
redirect_to signin_url require_login
else else
session[:atime] = Time.now.utc.to_i session[:atime] = Time.now.utc.to_i
end end

View File

@ -56,14 +56,14 @@ class SessionsTest < ActionController::TestCase
def test_user_session_without_ctime_should_be_reset_if_lifetime_enabled def test_user_session_without_ctime_should_be_reset_if_lifetime_enabled
with_settings :session_lifetime => '720' do with_settings :session_lifetime => '720' do
get :index, {}, {:user_id => 2} get :index, {}, {:user_id => 2}
assert_redirected_to '/login' assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
end end
end end
def test_user_session_with_expired_ctime_should_be_reset_if_lifetime_enabled def test_user_session_with_expired_ctime_should_be_reset_if_lifetime_enabled
with_settings :session_timeout => '720' do with_settings :session_timeout => '720' do
get :index, {}, {:user_id => 2, :atime => 2.days.ago.utc.to_i} get :index, {}, {:user_id => 2, :atime => 2.days.ago.utc.to_i}
assert_redirected_to '/login' assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
end end
end end
@ -77,14 +77,14 @@ class SessionsTest < ActionController::TestCase
def test_user_session_without_atime_should_be_reset_if_timeout_enabled def test_user_session_without_atime_should_be_reset_if_timeout_enabled
with_settings :session_timeout => '60' do with_settings :session_timeout => '60' do
get :index, {}, {:user_id => 2} get :index, {}, {:user_id => 2}
assert_redirected_to '/login' assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
end end
end end
def test_user_session_with_expired_atime_should_be_reset_if_timeout_enabled def test_user_session_with_expired_atime_should_be_reset_if_timeout_enabled
with_settings :session_timeout => '60' do with_settings :session_timeout => '60' do
get :index, {}, {:user_id => 2, :atime => 4.hours.ago.utc.to_i} get :index, {}, {:user_id => 2, :atime => 4.hours.ago.utc.to_i}
assert_redirected_to '/login' assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
end end
end end
@ -117,7 +117,7 @@ class SessionsTest < ActionController::TestCase
with_settings :session_timeout => '60' do with_settings :session_timeout => '60' do
get :index, {}, {:user_id => user.id, :atime => 4.hours.ago.utc.to_i} get :index, {}, {:user_id => user.id, :atime => 4.hours.ago.utc.to_i}
assert_redirected_to '/login' assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
assert_include "Veuillez vous reconnecter", flash[:error] assert_include "Veuillez vous reconnecter", flash[:error]
assert_equal :fr, current_language assert_equal :fr, current_language
end end