Create LndHub accounts
This commit is contained in:
15
app/jobs/create_lndhub_wallet_job.rb
Normal file
15
app/jobs/create_lndhub_wallet_job.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class CreateLndhubWalletJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(user)
|
||||
res = Faraday.post("#{ENV["LNDHUB_API_URL"]}/create",
|
||||
{ partnerid: "bluewallet", accounttype: "common" }.to_json,
|
||||
"Content-Type" => "application/json")
|
||||
|
||||
credentials = JSON.parse(res.body)
|
||||
|
||||
user.update! ln_login: credentials["login"],
|
||||
ln_password: credentials["password"]
|
||||
end
|
||||
|
||||
end
|
||||
@@ -10,6 +10,9 @@ class User < ApplicationRecord
|
||||
validates_uniqueness_of :email
|
||||
validates :email, email: true
|
||||
|
||||
encrypts :ln_login
|
||||
encrypts :ln_password
|
||||
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
||||
devise :ldap_authenticatable,
|
||||
|
||||
@@ -10,6 +10,7 @@ class CreateAccount < ApplicationService
|
||||
def call
|
||||
user = create_user_in_database
|
||||
add_ldap_document
|
||||
create_lndhub_wallet
|
||||
|
||||
if @invitation.present?
|
||||
update_invitation(user.id)
|
||||
@@ -44,4 +45,8 @@ class CreateAccount < ApplicationService
|
||||
return if Rails.env.development?
|
||||
ExchangeXmppContactsJob.perform_later(@invitation.user, @username, @domain)
|
||||
end
|
||||
|
||||
def create_lndhub_wallet
|
||||
CreateLndhubWalletJob.perform_later(user)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user