Class: IAMUser

Inherits:
User show all
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

Instance Method Summary collapse

Methods inherited from User

#account, #account_id, #account_uuid, #active_mhv_ids, #address, #all_emails, #birth_date, #birth_date_mpi, #can_access_id_card?, #can_access_user_profile?, #can_access_vet360?, #credential_lock, #deceased_date, #destroy, #edipi_mpi, #first_name, #first_name_mpi, #flipper_id, #full_name_normalized, #gender, #gender_mpi, #given_names, #home_phone, #icn, #in_progress_forms, #inherited_proof_verified, #invalidate_mpi_cache, #last_name, #last_name_mpi, #loa, #mhv_account_state, #mhv_ids, #middle_name, #middle_name_mpi, #military_information, #mpi_gcids, #mpi_profile?, #needs_accepted_terms_of_use, #normalized_suffix, #pciu_alternate_phone, #pciu_email, #pciu_primary_phone, #postal_code, #power_of_attorney, #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_treatment_facility_ids, #veteran_status, #vha_facility_hash, #vha_facility_ids

Methods included from Authorization

#authorize

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

Parameters:

Returns:

  • (IAMUser)

    an instance of this class



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_nameObject



50
51
52
# File 'app/models/iam_user.rb', line 50

def common_name
  "#{identity.first_name} #{identity.last_name}"
end

#edipiString

Where to get the edipi from If iam_edipi available return that otherwise hit MVI

Returns:

  • (String)

    the users DoD EDIPI



38
39
40
# File 'app/models/iam_user.rb', line 38

def edipi
  loa3? && iam_edipi.present? ? iam_edipi : mpi&.edipi
end

#idString

Return the uuid as the id for the user. This id is generated within the IAMUserIdentity class.

Returns:

  • (String)

    UUID that is unique to this user



46
47
48
# File 'app/models/iam_user.rb', line 46

def id
  uuid
end

#identityObject



54
55
56
# File 'app/models/iam_user.rb', line 54

def identity
  @identity ||= IAMUserIdentity.find(uuid)
end

#mhv_account_typeObject



62
63
64
# File 'app/models/iam_user.rb', line 62

def 
  MHVAccountTypeService.new(self).
end

#sec_idObject



58
59
60
# File 'app/models/iam_user.rb', line 58

def sec_id
  identity.iam_sec_id || sec_id
end

#set_expireObject



74
75
76
# File 'app/models/iam_user.rb', line 74

def set_expire
  redis_namespace.expireat(REDIS_CONFIG[:iam_user][:namespace], expiration_timestamp)
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.

Returns:

  • (Boolean)


70
71
72
# File 'app/models/iam_user.rb', line 70

def va_patient?
  mhv_correlation_id.present?
end

#vet360_contact_infoObject



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