mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 10:45:58 +02:00
Multiple users
This commit is contained in:
parent
66d7d80bcc
commit
e945bcf1f1
2 changed files with 27 additions and 13 deletions
|
@ -3,7 +3,7 @@ module Legacy
|
||||||
self.table_name = :registrar
|
self.table_name = :registrar
|
||||||
|
|
||||||
has_many :invoices, foreign_key: :registrarid
|
has_many :invoices, foreign_key: :registrarid
|
||||||
has_one :acl, foreign_key: :registrarid, class_name: "Legacy::RegistrarAcl"
|
has_many :acl, foreign_key: :registrarid, class_name: "Legacy::RegistrarAcl"
|
||||||
|
|
||||||
def account_balance
|
def account_balance
|
||||||
invoices.sum(:credit)
|
invoices.sum(:credit)
|
||||||
|
|
|
@ -141,19 +141,33 @@ namespace :import do
|
||||||
next if existing_ids.include?(x.id)
|
next if existing_ids.include?(x.id)
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
users << ApiUser.new({
|
if x.acl.last.try(:cert) != 'pki'
|
||||||
username: x.handle.try(:strip),
|
if x.acl.last.try(:cert) != 'idkaart'
|
||||||
password: x.acl.try(:password),
|
users << ApiUser.new({
|
||||||
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
username: x.handle.try(:strip),
|
||||||
legacy_id: x.try(:id)
|
password: x.acl.last.try(:password) ? x.acl.last.try(:password) : x.acl.first.try(:password),
|
||||||
})
|
identity_code: x.handle.try(:strip),
|
||||||
|
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
||||||
|
legacy_id: x.try(:id)
|
||||||
|
})
|
||||||
|
else
|
||||||
|
users << ApiUser.new({
|
||||||
|
username: x.handle.try(:strip),
|
||||||
|
password: x.acl.last.try(:password) ? x.acl.last.try(:password) : x.acl.first.try(:password),
|
||||||
|
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
||||||
|
legacy_id: x.try(:id)
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if x.acl.try(:ipaddr)
|
x.acl.all.each do |y|
|
||||||
ips << WhiteIp.new({
|
if !y.ipaddr.nil? && y.ipaddr != ''
|
||||||
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
ips << WhiteIp.new({
|
||||||
ipv4: x.acl.try(:ipaddr)
|
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
||||||
})
|
ipv4: y.ipaddr
|
||||||
end
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ApiUser.import users, validate: false
|
ApiUser.import users, validate: false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue