2017-03-09 11:44:51 +00:00
|
|
|
module ApplicationController::ChecksMaintainance
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def check_maintenance(user)
|
|
|
|
return false if !check_maintenance_only(user)
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-03-09 11:44:51 +00:00
|
|
|
raise Exceptions::NotAuthorized, 'Maintenance mode enabled!'
|
|
|
|
end
|
|
|
|
|
|
|
|
# check maintenance mode
|
|
|
|
def check_maintenance_only(user)
|
|
|
|
return false if Setting.get('maintenance_mode') != true
|
|
|
|
return false if user.permissions?('admin.maintenance')
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-03-09 11:44:51 +00:00
|
|
|
Rails.logger.info "Maintenance mode enabled, denied login for user #{user.login}, it's no admin user."
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|