X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/151626d019fde352cd771aafd4847d4ef63e36e9..990f3eba4069f98a11d98f18b18d0e35bcf295f4:/app/controllers/application_controller.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7ac9e6402..7043d8206 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -160,6 +160,18 @@ class ApplicationController < ActionController::Base end end + ## + # to be used as a before_filter *after* authorize. this checks that + # the user is a moderator and, if not, returns a forbidden error. + # + def authorize_moderator(errormessage="Access restricted to moderators") + # check user is a moderator + unless @user.moderator? + render :text => errormessage, :status => :forbidden + return false + end + end + def check_database_readable(need_api = false) if STATUS == :database_offline or (need_api and STATUS == :api_offline) redirect_to :controller => 'site', :action => 'offline'