summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-16 23:30:44 -0700
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-16 23:30:44 -0700
commit03dba1fd4299e7a0364aa94a845aaeca60b0c286 (patch)
treefe0716cdf7e410278d1b2edc8ac4f5eb81de6e31 /lib/api/helpers.rb
parentdad831662ad6521dfaf404621b72e551d456ca5c (diff)
parentaefe2e952f33267ce38fb9270400f4f6f194d37b (diff)
downloadgitlab-ce-03dba1fd4299e7a0364aa94a845aaeca60b0c286.tar.gz
Merge pull request #5344 from amacarthur/thread-variable-fix
Fixing unsafe use of Thread.current variable :current_user
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 1db1f396389..edc662eaaab 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -27,6 +27,15 @@ module API
end
end
+ def set_current_user_for_thread
+ Thread.current[:current_user] = current_user
+ begin
+ yield
+ ensure
+ Thread.current[:current_user] = nil
+ end
+ end
+
def user_project
@project ||= find_project(params[:id])
@project || not_found!