From 8b379465a5be48c8062379a3dea8e58110c52d87 Mon Sep 17 00:00:00 2001
From: tiagonbotelho <tiagonbotelho@hotmail.com>
Date: Mon, 21 Nov 2016 11:42:10 +0000
Subject: [PATCH] Reenables /user API request to return private-token if user
 is admin and requested with sudo

---
 lib/api/entities.rb | 1 +
 lib/api/users.rb    | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 899d68bc6c7..1dd191161ef 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -32,6 +32,7 @@ module API
       expose :can_create_project?, as: :can_create_project
       expose :two_factor_enabled?, as: :two_factor_enabled
       expose :external
+      expose :private_token, if: lambda { |user, options| user.is_admin? && options[:sudo_identifier] }
     end
 
     class UserLogin < UserFull
diff --git a/lib/api/users.rb b/lib/api/users.rb
index bc2362aa72e..b3870e0c7c8 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -353,7 +353,7 @@ module API
         success Entities::UserFull
       end
       get do
-        present current_user, with: Entities::UserFull
+        present current_user, with: Entities::UserFull, sudo_identifier: sudo_identifier
       end
 
       desc "Get the currently authenticated user's SSH keys" do
-- 
GitLab