mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 16:02:03 +02:00
Read IDC data and create user
This commit is contained in:
parent
f621764e92
commit
a52e76e319
3 changed files with 24 additions and 5 deletions
|
@ -1,8 +1,22 @@
|
|||
class RegistrantUser < User
|
||||
attr_accessor :registrar_typeahead
|
||||
attr_accessor :idc_data
|
||||
|
||||
def ability
|
||||
@ability ||= Ability.new(self)
|
||||
end
|
||||
delegate :can?, :cannot?, to: :ability
|
||||
|
||||
def to_s
|
||||
registrant_ident
|
||||
end
|
||||
|
||||
class << self
|
||||
def find_or_create_by_idc_data(idc_data)
|
||||
return false if idc_data.blank?
|
||||
identity_code = idc_data.scan(/serialNumber=(\d+)/).flatten.first
|
||||
country = idc_data.scan(/^\/C=(.{2})/).flatten.first
|
||||
|
||||
where(registrant_ident: "#{country}-#{identity_code}").first_or_create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue