mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 22:34:47 +00:00
* 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`
44 lines
1017 B
Ruby
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
|