akkounts/app/controllers/admin/lightning_controller.rb
Râu Cao b4c9b31ce7
Some checks failed
continuous-integration/drone/push Build is failing
Disable lndhub admin UI when not configured
2023-02-13 21:57:06 +08:00

22 lines
607 B
Ruby

class Admin::LightningController < Admin::BaseController
before_action :check_feature_enabled
def index
@current_section = :lightning
@users = User.pluck(:cn, :ou, :ln_account)
@accounts = LndhubAccount.with_balances.order(balance: :desc).to_a
@ln = {}
@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