diff --git a/app/controllers/admin/lightning_controller.rb b/app/controllers/admin/lightning_controller.rb index bd7ca99..10e6267 100644 --- a/app/controllers/admin/lightning_controller.rb +++ b/app/controllers/admin/lightning_controller.rb @@ -1,4 +1,6 @@ class Admin::LightningController < Admin::BaseController + before_action :check_feature_enabled + def index @current_section = :lightning @@ -9,4 +11,11 @@ class Admin::LightningController < Admin::BaseController @ln[:current_balance] = LndhubAccount.current.joins(:ledgers).sum("account_ledgers.amount") @ln[:users_with_sats] = @accounts.length end + + def check_feature_enabled + if ENV["LNDHUB_ADMIN_UI"].empty? + flash[:alert] = "Lightning Admin UI not enabled" + redirect_to admin_root_path and return + end + end end diff --git a/app/views/shared/_admin_nav.html.erb b/app/views/shared/_admin_nav.html.erb index b7ef06e..00a0fe8 100644 --- a/app/views/shared/_admin_nav.html.erb +++ b/app/views/shared/_admin_nav.html.erb @@ -6,5 +6,7 @@ class: main_nav_class(@current_section, :invitations) %> <%= link_to "Donations", admin_donations_path, class: main_nav_class(@current_section, :donations) %> -<%= link_to "Lightning", admin_lightning_path, - class: main_nav_class(@current_section, :lightning) %> +<% if ENV["LNDHUB_ADMIN_UI"] %> + <%= link_to "Lightning", admin_lightning_path, + class: main_nav_class(@current_section, :lightning) %> +<% end %>