Class: Account
Overview
Account’s purpose is to correlate unique identifiers, and to remove our dependency on third party services for a user’s unique identifier.
The account.uuid is intended to become the Vets-API user’s uuid.
Class Method Summary
collapse
Instance Method Summary
collapse
descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?
Class Method Details
.lookup_by_user_account_uuid(user_uuid) ⇒ Object
62
63
64
65
66
67
|
# File 'app/models/account.rb', line 62
def self.lookup_by_user_account_uuid(user_uuid)
user_account = UserAccount.find_by(id: user_uuid)
return unless user_account&.icn
Account.where(icn: user_account.icn).first
end
|
.lookup_by_user_uuid(user_uuid) ⇒ Object
52
53
54
55
56
57
58
|
# File 'app/models/account.rb', line 52
def self.lookup_by_user_uuid(user_uuid)
return if user_uuid.blank?
Account.find_by(idme_uuid: user_uuid) ||
Account.find_by(logingov_uuid: user_uuid) ||
lookup_by_user_account_uuid(user_uuid)
end
|
Instance Method Details
#generate_uuid ⇒ Object
81
82
83
|
# File 'app/models/account.rb', line 81
def generate_uuid
SecureRandom.uuid
end
|
#initialize_uuid ⇒ Object
71
72
73
74
75
|
# File 'app/models/account.rb', line 71
def initialize_uuid
new_uuid = generate_uuid
new_uuid = generate_uuid until unique?(new_uuid)
self.uuid = new_uuid
end
|
#unique?(new_uuid) ⇒ Boolean
77
78
79
|
# File 'app/models/account.rb', line 77
def unique?(new_uuid)
true unless Account.exists?(uuid: new_uuid)
end
|