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
This commit is contained in:
parent
66420fe4b7
commit
9072753489
@ -28,18 +28,23 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def user_setup
|
def user_setup
|
||||||
|
# Check the settings cache for each request
|
||||||
Setting.check_cache
|
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]
|
if session[:user_id]
|
||||||
# existing session
|
# existing session
|
||||||
User.current = User.find(session[:user_id])
|
(User.find_active(session[:user_id]) rescue nil)
|
||||||
elsif cookies[:autologin] && Setting.autologin?
|
elsif cookies[:autologin] && Setting.autologin?
|
||||||
# auto-login feature
|
# 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])
|
elsif params[:key] && accept_key_auth_actions.include?(params[:action])
|
||||||
# RSS key authentication
|
# RSS key authentication
|
||||||
User.current = User.find_by_rss_key(params[:key])
|
User.find_by_rss_key(params[:key])
|
||||||
else
|
|
||||||
User.current = User.anonymous
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user