comparison app/controllers/account_controller.rb @ 511:107d36338b70 live

Merge from branch "cannam"
author Chris Cannam
date Thu, 14 Jul 2011 10:43:07 +0100
parents 73ff0e6a11b1
children 5e80956cc792
comparison
equal deleted inserted replaced
451:a9f6345cb43d 511:107d36338b70
214 def successful_authentication(user) 214 def successful_authentication(user)
215 # Valid user 215 # Valid user
216 self.logged_user = user 216 self.logged_user = user
217 # generate a key and set cookie if autologin 217 # generate a key and set cookie if autologin
218 if params[:autologin] && Setting.autologin? 218 if params[:autologin] && Setting.autologin?
219 token = Token.create(:user => user, :action => 'autologin') 219 set_autologin_cookie(user)
220 cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }
221 end 220 end
222 call_hook(:controller_account_success_authentication_after, {:user => user }) 221 call_hook(:controller_account_success_authentication_after, {:user => user })
223 redirect_back_or_default :controller => 'my', :action => 'page' 222 redirect_back_or_default :controller => 'my', :action => 'page'
223 end
224
225 def set_autologin_cookie(user)
226 token = Token.create(:user => user, :action => 'autologin')
227 cookie_name = Redmine::Configuration['autologin_cookie_name'] || 'autologin'
228 cookie_options = {
229 :value => token.value,
230 :expires => 1.year.from_now,
231 :path => (Redmine::Configuration['autologin_cookie_path'] || '/'),
232 :secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false),
233 :httponly => true
234 }
235 cookies[cookie_name] = cookie_options
224 end 236 end
225 237
226 # Onthefly creation failed, display the registration form to fill/fix attributes 238 # Onthefly creation failed, display the registration form to fill/fix attributes
227 def onthefly_creation_failed(user, auth_source_options = { }) 239 def onthefly_creation_failed(user, auth_source_options = { })
228 @user = user 240 @user = user