summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-12-18 10:31:21 +0000
committerPhil Hughes <me@iamphill.com>2017-12-18 10:31:21 +0000
commit0a05d8740ac710b814a8f89cec3fc85d6fae6be9 (patch)
treee28de222d7d7334d6784be7f612e7763f016ae4a /lib/api/helpers.rb
parenteaf2f48dc7db706fa1dea050543667f8cdebd4c4 (diff)
parentb4ea25cafa0c7768a8618c673f9a1830f27fc950 (diff)
downloadgitlab-ce-ph-es-notes-module.tar.gz
Merge branch 'master' into 'ph-es-notes-module'ph-es-notes-module
# Conflicts: # app/assets/javascripts/main.js
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 686bf7a3c2b..9ba15893f55 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -32,6 +32,11 @@ module API
end
end
+ # rubocop:disable Gitlab/ModuleWithInstanceVariables
+ # We can't rewrite this with StrongMemoize because `sudo!` would
+ # actually write to `@current_user`, and `sudo?` would immediately
+ # call `current_user` again which reads from `@current_user`.
+ # We should rewrite this in a way that using StrongMemoize is possible
def current_user
return @current_user if defined?(@current_user)
@@ -45,6 +50,7 @@ module API
@current_user
end
+ # rubocop:enable Gitlab/ModuleWithInstanceVariables
def sudo?
initial_current_user != current_user
@@ -415,6 +421,7 @@ module API
private
+ # rubocop:disable Gitlab/ModuleWithInstanceVariables
def initial_current_user
return @initial_current_user if defined?(@initial_current_user)
@@ -424,6 +431,7 @@ module API
unauthorized!
end
end
+ # rubocop:enable Gitlab/ModuleWithInstanceVariables
def sudo!
return unless sudo_identifier
@@ -443,7 +451,7 @@ module API
sudoed_user = find_user(sudo_identifier)
not_found!("User with ID or username '#{sudo_identifier}'") unless sudoed_user
- @current_user = sudoed_user
+ @current_user = sudoed_user # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
def sudo_identifier