1 module CurrentApiClient
7 Thread.current[:api_client]
10 def current_api_client_authorization
11 Thread.current[:api_client_authorization]
14 def current_default_owner
15 # owner uuid for newly created objects
16 ((current_api_client_authorization &&
17 current_api_client_authorization.default_owner) ||
18 (current_user && current_user.default_owner) ||
19 (current_user && current_user.uuid) ||
23 # Where is the client connecting from?
24 def current_api_client_ip_address
25 Thread.current[:api_client_ip_address]
28 # Is the current client permitted to perform ALL actions on behalf
29 # of the authenticated user?
30 def current_api_client_trusted
31 Thread.current[:api_client_trusted]
35 [Server::Application.config.uuid_prefix,
37 '000000000000000'].join('-')
42 real_current_user = Thread.current[:user]
43 Thread.current[:user] = User.new(is_admin: true)
44 $system_user = User.where('uuid=?', system_user_uuid).first
46 $system_user = User.new(uuid: system_user_uuid,
54 Thread.current[:user] = real_current_user
59 def act_as_system_user
60 Thread.current[:user] = system_user