ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

cookie_name.patch

Ted P, 2011-03-13 02:48 am

Download (2.2 kB)

 
app/controllers/account_controller.rb
129 129
  
130 130
  def logout_user
131 131
    if User.current.logged?
132
      cookies.delete :autologin
132
      cookie_name = Redmine::Configuration['autologin_cookie_name'] || 'autologin'
133
      cookies.delete cookie_name
133 134
      Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin'])
134 135
      self.logged_user = nil
135 136
    end
app/controllers/application_controller.rb
60 60
  # Returns the current user or nil if no user is logged in
61 61
  # and starts a session if needed
62 62
  def find_current_user
63
    cookie_name = Redmine::Configuration['autologin_cookie_name'] || 'autologin'
63 64
    if session[:user_id]
64 65
      # existing session
65 66
      (User.active.find(session[:user_id]) rescue nil)
66
    elsif cookies[:autologin] && Setting.autologin?
67
    elsif cookies[cookie_name] && Setting.autologin?
67 68
      # auto-login feature starts a new session
68
      user = User.try_to_autologin(cookies[:autologin])
69
      user = User.try_to_autologin(cookies[cookie_name])
69 70
      session[:user_id] = user.id if user
70 71
      user
71 72
    elsif params[:format] == 'atom' && params[:key] && accept_key_auth_actions.include?(params[:action])
test/integration/account_test.rb
60 60
    assert_nil user.reload.last_login_on
61 61
    
62 62
    # User comes back with his autologin cookie
63
    cookies[:autologin] = token.value
63
    cookie_name = Redmine::Configuration['autologin_cookie_name'] || 'autologin'
64
    cookies[cookie_name] = token.value
64 65
    get '/my/page'
65 66
    assert_response :success
66 67
    assert_template 'my/page'