2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
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
|
2021-09-22 14:57:27 +00:00
|
|
|
Thread.current[:assets] = UserInfo::Assets.new(user_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.assets
|
|
|
|
Thread.current[:assets]
|
2012-04-10 14:30:10 +00:00
|
|
|
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
|
2019-07-12 13:59:18 +00:00
|
|
|
ensure
|
|
|
|
UserInfo.current_user_id = nil if reset_current_user_id
|
2017-04-27 08:17:10 +00:00
|
|
|
end
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|