summaryrefslogtreecommitdiff
path: root/lib/api/users.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-12-09 18:48:20 +0100
committerRémy Coutable <remy@rymai.me>2016-12-12 13:50:31 +0100
commit2f45d3bcf0f28d4cd4124b4c9722edc1d3085201 (patch)
tree4678734e87bd2d7e7c8819bf352908b74f8c14e1 /lib/api/users.rb
parent0f6964a38527e648551e981157d5489d4c301b76 (diff)
downloadgitlab-ce-2f45d3bcf0f28d4cd4124b4c9722edc1d3085201.tar.gz
API: Memoize the current_user so that the sudo can work properly
The issue was arising when `#current_user` was called a second time after a user was impersonated: the `User#is_admin?` check would be performed on it and it would fail. Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib/api/users.rb')
-rw-r--r--lib/api/users.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb
index 1dab799dd61..c7db2d71017 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -353,7 +353,7 @@ module API
success Entities::UserPublic
end
get do
- present current_user, with: @impersonator ? Entities::UserWithPrivateToken : Entities::UserPublic
+ present current_user, with: sudo? ? Entities::UserWithPrivateToken : Entities::UserPublic
end
desc "Get the currently authenticated user's SSH keys" do