diff --git a/app/models/setting.rb b/app/models/setting.rb index 5114501..e51ead6 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -113,6 +113,9 @@ class Setting < RailsSettings::Base field :lndhub_enabled, type: :boolean, default: (ENV["LNDHUB_API_URL"].present?.to_s || false) + field :lndhub_admin_token, type: :string, + default: ENV["LNDHUB_ADMIN_TOKEN"].presence + field :lndhub_admin_enabled, type: :boolean, default: (ENV["LNDHUB_ADMIN_UI"] || false) diff --git a/app/services/lndhub_v2.rb b/app/services/lndhub_v2.rb index e0a84dd..b816fcb 100644 --- a/app/services/lndhub_v2.rb +++ b/app/services/lndhub_v2.rb @@ -14,7 +14,7 @@ class LndhubV2 < Lndhub end def create_account(payload={}) - post "v2/users", payload, admin_token: Rails.application.credentials.lndhub[:admin_token] + post "v2/users", payload, admin_token: Setting.lndhub_admin_token end def create_invoice(payload) diff --git a/app/views/admin/settings/services/_lndhub.html.erb b/app/views/admin/settings/services/_lndhub.html.erb index a68ad37..ac679c4 100644 --- a/app/views/admin/settings/services/_lndhub.html.erb +++ b/app/views/admin/settings/services/_lndhub.html.erb @@ -9,29 +9,35 @@ ) %> <% if Setting.lndhub_enabled? %> <%= render FormElements::FieldsetResettableSettingComponent.new( - key: :lndhub_api_url, - title: "API URL" - ) %> - <% end %> - <%= render FormElements::FieldsetToggleComponent.new( - form: f, - attribute: :lndhub_admin_enabled, - enabled: Setting.lndhub_admin_enabled?, - title: "Enable LNDHub admin panel", - description: "LNDHub database configuration present and admin panel enabled" - ) %> - <%= render FormElements::FieldsetToggleComponent.new( - form: f, - attribute: :lndhub_keysend_enabled, - enabled: Setting.lndhub_keysend_enabled?, - title: "Enable keysend payments", - description: "Allow users to receive invoice-less payments to their Lightning Address" - ) %> - <% if Setting.lndhub_keysend_enabled? %> + key: :lndhub_api_url, + title: "API URL" + ) %> <%= render FormElements::FieldsetResettableSettingComponent.new( - key: :lndhub_public_key, - title: "Public key", - description: "The public key of the Lightning node used by LNDHub" - ) %> + key: :lndhub_admin_token, + type: :password, + title: "Admin token", + description: "Auth token for creating new lndhub accounts" + ) %> + <%= render FormElements::FieldsetToggleComponent.new( + form: f, + attribute: :lndhub_admin_enabled, + enabled: Setting.lndhub_admin_enabled?, + title: "Enable LNDHub admin panel", + description: "LNDHub database configuration present and admin panel enabled" + ) %> + <%= render FormElements::FieldsetToggleComponent.new( + form: f, + attribute: :lndhub_keysend_enabled, + enabled: Setting.lndhub_keysend_enabled?, + title: "Enable keysend payments", + description: "Allow users to receive invoice-less payments to their Lightning Address" + ) %> + <% if Setting.lndhub_keysend_enabled? %> + <%= render FormElements::FieldsetResettableSettingComponent.new( + key: :lndhub_public_key, + title: "Public key", + description: "The public key of the Lightning node used by LNDHub" + ) %> + <% end %> <% end %>