Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-12-09 20:48:20 +0300
committerRémy Coutable <remy@rymai.me>2016-12-12 15:50:31 +0300
commit2f45d3bcf0f28d4cd4124b4c9722edc1d3085201 (patch)
tree4678734e87bd2d7e7c8819bf352908b74f8c14e1 /lib/api/users.rb
parent0f6964a38527e648551e981157d5489d4c301b76 (diff)
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