0001-Set-a-back_url-when-forcing-new-login-after-session-.patch

Holger Just, 2015-04-17 16:47

Download (3.05 KB)

View differences:

app/controllers/application_controller.rb
63 63
    if session[:user_id]
64 64
      if session_expired? && !try_to_autologin
65 65
        set_localization(User.active.find_by_id(session[:user_id]))
66
        reset_session
66
        self.logged_user = nil
67 67
        flash[:error] = l(:error_session_expired)
68
        redirect_to signin_url
68
        require_login
69 69
      else
70 70
        session[:atime] = Time.now.utc.to_i
71 71
      end
test/functional/sessions_test.rb
56 56
  def test_user_session_without_ctime_should_be_reset_if_lifetime_enabled
57 57
    with_settings :session_lifetime => '720' do
58 58
      get :index, {}, {:user_id => 2}
59
      assert_redirected_to '/login'
59
      assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
60 60
    end
61 61
  end
62 62

  
63 63
  def test_user_session_with_expired_ctime_should_be_reset_if_lifetime_enabled
64 64
    with_settings :session_timeout => '720' do
65 65
      get :index, {}, {:user_id => 2, :atime => 2.days.ago.utc.to_i}
66
      assert_redirected_to '/login'
66
      assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
67 67
    end
68 68
  end
69 69

  
......
77 77
  def test_user_session_without_atime_should_be_reset_if_timeout_enabled
78 78
    with_settings :session_timeout => '60' do
79 79
      get :index, {}, {:user_id => 2}
80
      assert_redirected_to '/login'
80
      assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
81 81
    end
82 82
  end
83 83

  
84 84
  def test_user_session_with_expired_atime_should_be_reset_if_timeout_enabled
85 85
    with_settings :session_timeout => '60' do
86 86
      get :index, {}, {:user_id => 2, :atime => 4.hours.ago.utc.to_i}
87
      assert_redirected_to '/login'
87
      assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
88 88
    end
89 89
  end
90 90

  
......
117 117

  
118 118
    with_settings :session_timeout => '60' do
119 119
      get :index, {}, {:user_id => user.id, :atime => 4.hours.ago.utc.to_i}
120
      assert_redirected_to '/login'
120
      assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F'
121 121
      assert_include "Veuillez vous reconnecter", flash[:error]
122 122
      assert_equal :fr, current_language
123 123
    end
124
-