summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-12-15 21:25:23 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-12-15 21:25:23 +0000
commit223cb3788a744f9b1b92959d3337000358db108b (patch)
tree77858e7ec0e2a731ddb7791f99d75ef4c23b4b54 /lib/api/helpers.rb
parentb3606cff38b9defc764706ed6529a9e27dcf4847 (diff)
parenta1a323392d4f0cb59eab2e215fa4010b84fc122d (diff)
downloadgitlab-ce-41117-empty-state.tar.gz
Merge branch 'master' into 41117-empty-state41117-empty-state
* master: (71 commits) Update CHANGELOG.md for 10.2.5 Change CI config to use new base image fix issue #39843 Incorrect guidance stating blocked users will be removed from groups and projects as members Add changelog entry Update tests for toggle design change Update toggle styles to use icons Use icons instead of string labels for toggles Fix Rubocop offense in QA project specs Add SAST docs Fix UX issues in system info page Update svg package version Make sure user email is read only when synced with LDAP Add note about automatic pipelines when enabling Auto DevOps Backport changes from EE Docs update documentation guidelines Don't use Markdown cache for stubbed settings in specs Fix remaining calls to GitLab QA factories Rename QA scenarios to make factory concept explicit Export JS classes as modules Make rubocop happy ...
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