X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/78b9d92207bb215459ecff466c3efe2fa6466ab3..e04ddc3e1538b708140440708d2d1d3c5cb56154:/app/controllers/application_controller.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9f2d79eaa..d571535d3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,6 @@ class ApplicationController < ActionController::Base + require "timeout" + include SessionPersistence protect_from_forgery :with => :exception @@ -57,7 +59,7 @@ class ApplicationController < ActionController::Base def require_user unless current_user if request.get? - redirect_to :controller => "users", :action => "login", :referer => request.fullpath + redirect_to login_path(:referer => request.fullpath) else head :forbidden end @@ -229,7 +231,7 @@ class ApplicationController < ActionController::Base ## # wrap an api call in a timeout def api_call_timeout(&block) - OSM::Timer.timeout(Settings.api_timeout, Timeout::Error, &block) + Timeout.timeout(Settings.api_timeout, Timeout::Error, &block) rescue Timeout::Error raise OSM::APITimeoutError end @@ -237,7 +239,7 @@ class ApplicationController < ActionController::Base ## # wrap a web page in a timeout def web_timeout(&block) - OSM::Timer.timeout(Settings.web_timeout, Timeout::Error, &block) + Timeout.timeout(Settings.web_timeout, Timeout::Error, &block) rescue ActionView::Template::Error => e e = e.cause @@ -354,7 +356,7 @@ class ApplicationController < ActionController::Base end elsif request.get? respond_to do |format| - format.html { redirect_to :controller => "users", :action => "login", :referer => request.fullpath } + format.html { redirect_to login_path(:referer => request.fullpath) } format.any { head :forbidden } end else @@ -391,6 +393,8 @@ class ApplicationController < ActionController::Base referer = nil end + referer = nil if referer&.path&.first != "/" + referer.to_s end end