]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/application_controller.rb
Use system_timer for timeouts to make them more reliable.
[rails.git] / app / controllers / application_controller.rb
index acadfcc251fa13597ca0a6f9763305a1f04a72c9..53ad1e901c8d41187d3e588c95b8cd72161ea290 100644 (file)
@@ -208,9 +208,11 @@ class ApplicationController < ActionController::Base
   end
 
   def api_call_timeout
-    Timeout::timeout(APP_CONFIG['api_timeout'], OSM::APITimeoutError) do
+    SystemTimer.timeout_after(APP_CONFIG['api_timeout']) do
       yield
     end
+  rescue Timeout::Error
+    raise OSM::APITimeoutError
   end
 
   ##
@@ -244,6 +246,12 @@ class ApplicationController < ActionController::Base
     expire_fragment(Regexp.new(Regexp.escape(path) + "\\..*"))
   end
 
+  ##
+  # is the requestor logged in?
+  def logged_in?
+    !@user.nil?
+  end
+
 private 
 
   # extract authorisation credentials from headers, returns user = nil if none