checks_maintainance.rb 552 B

123456789101112131415161718
  1. module ApplicationController::ChecksMaintainance
  2. extend ActiveSupport::Concern
  3. private
  4. def check_maintenance(user)
  5. return false if !check_maintenance_only(user)
  6. raise Exceptions::NotAuthorized, 'Maintenance mode enabled!'
  7. end
  8. # check maintenance mode
  9. def check_maintenance_only(user)
  10. return false if Setting.get('maintenance_mode') != true
  11. return false if user.permissions?('admin.maintenance')
  12. Rails.logger.info "Maintenance mode enabled, denied login for user #{user.login}, it's no admin user."
  13. true
  14. end
  15. end