X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/0a8c26e596b40da6d428a5c91db0d815d13c89e4..6d6c9ddc8c80215b015037254e019aa05f643741:/app/controllers/application.rb diff --git a/app/controllers/application.rb b/app/controllers/application.rb index bc61db5f9..acb2f9162 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -9,6 +9,9 @@ class ApplicationController < ActionController::Base @user = User.authenticate(:token => session[:token]) session[:user] = @user.id end + rescue Exception => ex + logger.info("Exception authorizing user: #{ex.to_s}") + @user = nil end def require_user @@ -36,8 +39,16 @@ class ApplicationController < ActionController::Base end end - def check_availability - if API_READONLY + def check_read_availability + if API_STATUS == :offline + response.headers['Error'] = "Database offline for maintenance" + render :nothing => true, :status => :service_unavailable + return false + end + end + + def check_write_availability + if API_STATUS == :offline or API_STATUS == :readonly response.headers['Error'] = "Database offline for maintenance" render :nothing => true, :status => :service_unavailable return false