Class: IAMUser
- Inherits:
-
User
- Object
- Common::RedisStore
- User
- IAMUser
- Defined in:
- app/models/iam_user.rb
Overview
Subclasses the ‘User` model. Adds a unique redis namespace for IAM users. Adds IAM sourced versions of ICN, EDIPI, and SEC ID and methods to use them or hit MPI via the mpi_profile.
Constant Summary
Constants inherited from User
User::ID_CARD_ALLOWED_STATUSES
Constants inherited from Common::RedisStore
Common::RedisStore::REQ_CLASS_INSTANCE_VARS
Class Method Summary collapse
-
.build_from_user_identity(user_identity) ⇒ IAMUser
Builds an user instance from a IAMUserIdentity.
Instance Method Summary collapse
- #common_name ⇒ Object
-
#edipi ⇒ String
Where to get the edipi from If iam_edipi available return that otherwise hit MVI.
-
#id ⇒ String
Return the uuid as the id for the user.
- #identity ⇒ Object
- #mhv_account_type ⇒ Object
- #sec_id ⇒ Object
- #set_expire ⇒ Object
-
#va_patient? ⇒ Boolean
This is not the correct way of determining VA patient status, but it works for authorizing access for existing MHV premium users If we are going to enable account creation/upgrade, then we’ll need to derive the list of facilities from the IAM introspection payload.
- #vet360_contact_info ⇒ Object
Methods inherited from User
#account, #account_id, #account_uuid, #active_mhv_ids, #address, #all_emails, #bgs_relationships, #birth_date, #birth_date_mpi, #can_access_id_card?, #can_access_user_profile?, #can_access_vet360?, #can_create_mhv_account?, #create_mhv_account_async, #credential_lock, #deceased_date, #destroy, #edipi_mpi, #first_name, #first_name_mpi, #flipper_id, #full_name_normalized, #gender, #gender_mpi, #get_relationships_array, #get_user_verification, #given_names, #home_phone, #icn, #in_progress_forms, #initial_sign_in, #invalidate_mpi_cache, #last_name, #last_name_mpi, #loa, #log_mhv_user_account_error, #mhv_account_state, #mhv_ids, #mhv_user_account, #middle_name, #middle_name_mpi, #mpi, #mpi_gcids, #mpi_profile, #mpi_profile?, #mpi_profile_relationships, #needs_accepted_terms_of_use, #normalized_suffix, #onboarding, #pciu, #pciu_alternate_phone, #pciu_email, #pciu_primary_phone, #postal_code, #power_of_attorney, #preferred_name, #preferred_name_mpi, #recache, #relationships, #served_in_military?, #set_mhv_ids, #ssn, #ssn_mismatch?, #ssn_mpi, #ssn_normalized, #suffix, #user_account, #user_account_uuid, #user_verification, #user_verification_id, #va_profile_email, #va_profile_v2_email, #va_treatment_facility_ids, #vaprofile_contact_info, #veteran_status, #vha_facility_hash, #vha_facility_ids
Methods included from Authorization
Methods inherited from Common::RedisStore
create, delete, #destroy, #destroyed?, exists?, #expire, find, find_or_build, #initialize, #initialize_dup, keys, #persisted?, pop, redis_key, redis_store, redis_ttl, #save, #save!, #ttl, #update, #update!
Constructor Details
This class inherits a constructor from Common::RedisStore
Class Method Details
.build_from_user_identity(user_identity) ⇒ IAMUser
Builds an user instance from a IAMUserIdentity
28 29 30 31 32 |
# File 'app/models/iam_user.rb', line 28 def self.build_from_user_identity(user_identity) user = new(user_identity.attributes) user.set_expire user end |
Instance Method Details
#common_name ⇒ Object
50 51 52 |
# File 'app/models/iam_user.rb', line 50 def common_name "#{identity.first_name} #{identity.last_name}" end |
#edipi ⇒ String
Where to get the edipi from If iam_edipi available return that otherwise hit MVI
38 39 40 |
# File 'app/models/iam_user.rb', line 38 def edipi loa3? && iam_edipi.present? ? iam_edipi : mpi&.edipi end |
#id ⇒ String
Return the uuid as the id for the user. This id is generated within the IAMUserIdentity class.
46 47 48 |
# File 'app/models/iam_user.rb', line 46 def id uuid end |
#identity ⇒ Object
54 55 56 |
# File 'app/models/iam_user.rb', line 54 def identity @identity ||= IAMUserIdentity.find(uuid) end |
#mhv_account_type ⇒ Object
62 63 64 |
# File 'app/models/iam_user.rb', line 62 def mhv_account_type MHVAccountTypeService.new(self).mhv_account_type end |
#sec_id ⇒ Object
58 59 60 |
# File 'app/models/iam_user.rb', line 58 def sec_id identity.iam_sec_id || sec_id end |
#set_expire ⇒ Object
74 75 76 |
# File 'app/models/iam_user.rb', line 74 def set_expire redis_namespace.expireat(REDIS_CONFIG[:iam_user][:namespace], ) end |
#va_patient? ⇒ Boolean
This is not the correct way of determining VA patient status, but it works for authorizing access for existing MHV premium users If we are going to enable account creation/upgrade, then we’ll need to derive the list of facilities from the IAM introspection payload.
70 71 72 |
# File 'app/models/iam_user.rb', line 70 def va_patient? mhv_correlation_id.present? end |
#vet360_contact_info ⇒ Object
78 79 80 81 82 83 84 |
# File 'app/models/iam_user.rb', line 78 def vet360_contact_info super rescue Faraday::ResourceNotFound raise Common::Exceptions::RecordNotFound, vet360_id rescue Common::Client::Errors::ClientError raise Common::Exceptions::BadGateway.new(id: vet360_id) end |