diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-12-30 10:51:34 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-12-30 10:51:34 +0000 |
commit | 9072753489d59bc02948b4a0ba20ff417e98c966 (patch) | |
tree | 5f10a3249e18055400b2d50351393db6a4745474 | |
parent | 66420fe4b7ece872c992a91e935a79258482068b (diff) | |
download | redmine-9072753489d59bc02948b4a0ba20ff417e98c966.tar.gz redmine-9072753489d59bc02948b4a0ba20ff417e98c966.zip |
Moved current user management to a dedicated method for modularity.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1029 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/application.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 607ac091b..306ebc03c 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -28,18 +28,23 @@ class ApplicationController < ActionController::Base end def user_setup + # Check the settings cache for each request Setting.check_cache + # Find the current user + User.current = find_current_user + end + + # Returns the current user or nil if no user is logged in + def find_current_user if session[:user_id] # existing session - User.current = User.find(session[:user_id]) + (User.find_active(session[:user_id]) rescue nil) elsif cookies[:autologin] && Setting.autologin? # auto-login feature - User.current = User.find_by_autologin_key(cookies[:autologin]) + User.find_by_autologin_key(cookies[:autologin]) elsif params[:key] && accept_key_auth_actions.include?(params[:action]) # RSS key authentication - User.current = User.find_by_rss_key(params[:key]) - else - User.current = User.anonymous + User.find_by_rss_key(params[:key]) end end |