summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorAngus MacArthur <amacarthur@blackberry.com>2013-10-04 15:11:50 -0400
committerAngus MacArthur <amacarthur@blackberry.com>2013-10-16 01:20:53 -0400
commitaefe2e952f33267ce38fb9270400f4f6f194d37b (patch)
tree3546807c2b7942585a41cfb1163dc5e6a69e40e0 /lib/api/helpers.rb
parenta8eb525e72f6883a07539af9429ccd41dbc8698b (diff)
downloadgitlab-ce-aefe2e952f33267ce38fb9270400f4f6f194d37b.tar.gz
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 2b0c672c7fa..e09a4660668 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -31,6 +31,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!