mirror of
https://github.com/internetee/registry.git
synced 2025-06-13 16:14:47 +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
|
attr_accessor :idc_data
|
||||||
|
|
||||||
devise :trackable, :timeoutable
|
devise :trackable, :timeoutable
|
||||||
|
after_save :update_related_contacts
|
||||||
|
|
||||||
def ability
|
def ability
|
||||||
@ability ||= Ability.new(self)
|
@ability ||= Ability.new(self)
|
||||||
|
@ -54,6 +55,12 @@ class RegistrantUser < User
|
||||||
username.split.second
|
username.split.second
|
||||||
end
|
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
|
class << self
|
||||||
def find_or_create_by_api_data(user_data = {})
|
def find_or_create_by_api_data(user_data = {})
|
||||||
return false unless user_data[:ident]
|
return false unless user_data[:ident]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue