2012-04-10 14:30:10 +00:00
|
|
|
module UserInfo
|
2013-04-20 08:52:17 +00:00
|
|
|
def self.current_user_id
|
2012-04-10 14:30:10 +00:00
|
|
|
Thread.current[:user_id]
|
|
|
|
end
|
2015-04-11 15:26:21 +00:00
|
|
|
|
2012-04-10 14:30:10 +00:00
|
|
|
def self.current_user_id=(user_id)
|
|
|
|
Thread.current[:user_id] = user_id
|
|
|
|
end
|
2017-04-27 08:17:10 +00:00
|
|
|
|
|
|
|
def self.ensure_current_user_id
|
|
|
|
if UserInfo.current_user_id.nil?
|
|
|
|
UserInfo.current_user_id = 1
|
|
|
|
reset_current_user_id = true
|
|
|
|
end
|
|
|
|
|
|
|
|
yield
|
|
|
|
|
|
|
|
return if !reset_current_user_id
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-04-27 08:17:10 +00:00
|
|
|
UserInfo.current_user_id = nil
|
|
|
|
end
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|