X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2a64d9ed4228b2aa1e52a206a67c23a5ea52f3f7..97ee2e7bfcdb17fd195382b22a15f0f2752b8007:/services/api/lib/current_api_client.rb diff --git a/services/api/lib/current_api_client.rb b/services/api/lib/current_api_client.rb index 24d8b3ada9..ab6d624ea5 100644 --- a/services/api/lib/current_api_client.rb +++ b/services/api/lib/current_api_client.rb @@ -30,4 +30,33 @@ module CurrentApiClient def current_api_client_trusted Thread.current[:api_client_trusted] end + + def system_user_uuid + [Server::Application.config.uuid_prefix, + User.uuid_prefix, + '000000000000000'].join('-') + end + + def system_user + if not $system_user + real_current_user = Thread.current[:user] + Thread.current[:user] = User.new(is_admin: true) + $system_user = User.where('uuid=?', system_user_uuid).first + if !$system_user + $system_user = User.new(uuid: system_user_uuid, + is_admin: true, + email: 'root', + first_name: 'root', + last_name: '') + $system_user.save! + $system_user.reload + end + Thread.current[:user] = real_current_user + end + $system_user + end + + def act_as_system_user + Thread.current[:user] = system_user + end end