Files
sure/app/controllers/concerns/self_hostable.rb
Juan José Mata 5706280dd7 More rebranding changes (#159)
* Replace Maybe for Sure in select code areas

* Make sure passwords are consistent

* Remove (admin|member) from demo data first name

* Database and schema names finally to `sure`

* Fix broken test

* Another (benchmarking) database name to `sure_*`

* More rebranding to Sure

* Missed this Maybe mention in the same page

* Random nitpicks and more Maybes

* Demo data accounts and more Maybes

* Test data account updates

* Impersonation test accounts

* Consistency with `compose.example.yml`
2025-09-24 00:19:51 +02:00

44 lines
1017 B
Ruby

module SelfHostable
extend ActiveSupport::Concern
included do
helper_method :self_hosted?, :self_hosted_first_login?
prepend_before_action :verify_self_host_config
end
private
def self_hosted?
Rails.configuration.app_mode.self_hosted?
end
def self_hosted_first_login?
self_hosted? && User.count.zero?
end
def verify_self_host_config
return unless self_hosted?
# Special handling for Redis configuration error page
if controller_name == "pages" && action_name == "redis_configuration_error"
# If Redis is now working, redirect to home
if redis_connected?
redirect_to root_path, notice: "Redis is now configured properly! You can now setup your Sure application."
end
return
end
unless redis_connected?
redirect_to redis_configuration_error_path
end
end
def redis_connected?
Redis.new.ping
true
rescue Redis::CannotConnectError
false
end
end