From aefe2e952f33267ce38fb9270400f4f6f194d37b Mon Sep 17 00:00:00 2001 From: Angus MacArthur Date: Fri, 4 Oct 2013 15:11:50 -0400 Subject: Fixing unsafe use of Thread.current variable :current_user --- lib/api/helpers.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/api/helpers.rb') 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! -- cgit v1.2.1