mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 23:24:48 +02:00
Update contact(s) name based on eIdentity data from Registrant API
This commit is contained in:
parent
083be0d536
commit
7a6568c34a
1 changed files with 7 additions and 0 deletions
|
@ -2,6 +2,7 @@ class RegistrantUser < User
|
|||
attr_accessor :idc_data
|
||||
|
||||
devise :trackable, :timeoutable
|
||||
after_save :update_related_contacts
|
||||
|
||||
def ability
|
||||
@ability ||= Ability.new(self)
|
||||
|
@ -54,6 +55,12 @@ class RegistrantUser < User
|
|||
username.split.second
|
||||
end
|
||||
|
||||
def update_related_contacts
|
||||
cc, idcode = registrant_ident.split('-')
|
||||
contacts = Contact.where(ident: idcode, country_code: cc).where('name != ?', username)
|
||||
contacts.each { |c| c.update(name: username) }
|
||||
end
|
||||
|
||||
class << self
|
||||
def find_or_create_by_api_data(user_data = {})
|
||||
return false unless user_data[:ident]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue