autologin.patch

Alik E, 2013-03-02 08:08

Download (2.8 KB)

View differences:

it-redmine/app/controllers/account_controller.rb 2013-03-01 23:01:04.642760286 -0800
169 169
  end
170 170

  
171 171
  def open_id_authenticate(openid_url)
172
    authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url, :method => :post) do |result, identity_url, registration|
172
    authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url(:autologin => params[:autologin]), :method => :post) do |result, identity_url, registration|
173

  
173 174
      if result.successful?
174 175
        user = User.find_or_initialize_by_identity_url(identity_url)
175 176
        if user.new_record?
......
223 224

  
224 225
  def set_autologin_cookie(user)
225 226
    token = Token.create(:user => user, :action => 'autologin')
226
    cookie_name = Redmine::Configuration['autologin_cookie_name'] || 'autologin'
227 227
    cookie_options = {
228 228
      :value => token.value,
229 229
      :expires => 1.year.from_now,
......
231 231
      :secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false),
232 232
      :httponly => true
233 233
    }
234
    cookies[cookie_name] = cookie_options
234
    cookies[autologin_cookie_name] = cookie_options
235 235
  end
236 236

  
237 237
  # Onthefly creation failed, display the registration form to fill/fix attributes
it-redmine/app/controllers/application_controller.rb 2013-03-01 22:56:16.730748635 -0800
32 32
  protect_from_forgery
33 33
  def handle_unverified_request
34 34
    super
35
    cookies.delete(:autologin)
35
    cookies.delete(autologin_cookie_name)
36 36
  end
37 37

  
38 38
  before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization
......
124 124
    user
125 125
  end
126 126

  
127
  def autologin_cookie_name
128
    return Redmine::Configuration['autologin_cookie_name'] || 'autologin'
129
  end
130

  
127 131
  def try_to_autologin
128
    if cookies[:autologin] && Setting.autologin?
132
    if cookies[autologin_cookie_name] && Setting.autologin?
129 133
      # auto-login feature starts a new session
130
      user = User.try_to_autologin(cookies[:autologin])
134
      user = User.try_to_autologin(cookies[autologin_cookie_name])
131 135
      if user
132 136
        reset_session
133 137
        start_user_session(user)