Odyssey
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
User Class Reference

Public Member Functions

 __construct (string $username, string $creditUnion, UserRepo $userRepo)
 
 __get (string $propertyName)
 
 __set (string $propertyName, string $value)
 
 __isset (String $propertyName)
 

Public Attributes

const MEM_UNUSED = 0
 
const MEM_FORCE_RESET = 2
 
const MEM_LOGIN_FAILED_EMAIL = 4
 
const MEM_LOGIN_FAILED_QST = 8
 
const MEM_LOGIN_FAILED_PWD = 16
 
const MEM_ASKBPAY = 32
 
const MEM_LOGIN_FAILED_ALIAS = 64
 
const MEM_LOGIN_FAILED_SAC = 128
 
const MEM_LOGIN_FAILED_BNDL = 256
 
const MEM_LOGIN_FAILED_BNDL_TIMEOUT = 512
 
const MSGTX_TRANSFER = 1
 
const MSGTX_ES = 2
 
const MSGTX_WEBCONNECT = 4
 
const MSGTX_TMP_SURVEY = 8
 
const MSGTX_TMP_XAC_RQ = 16
 
const MSGTX_TMP_XAX_LD = 32
 
const MSGTX_INTUITUPD = 64
 
const MSGTX_TXNDOWN = 128
 
const MSGTX_TMP_MKT = 256
 
const MSGTX_FORCE_EM = 512
 
const MSGTX_PASSCHG = 1024
 
const MSGTX_ONLINEDISC = 2048
 
const MSGTX_PROMOHIDE = 4096
 
const MSGTX_STICKY = 8192
 
const HCUTEMP_FLAGS = 49464
 
 $data = []
 
 $isUserLoaded = false
 

Private Member Functions

 Load ()
 
 DecodeMFAJson (array $mfaJson)
 
 GetAccounts ()
 

Private Attributes

 $username
 
 $creditUnion
 
 $userRepo
 
 $dirtyFields = []
 
 $allowedProperties
 
 $derivedProperties
 

Detailed Description

Model containing user login information

Definition at line 7 of file User.php.

Constructor & Destructor Documentation

◆ __construct()

User::__construct ( string  $username,
string  $creditUnion,
UserRepo  $userRepo 
)

User constructor.

Parameters
string$username
String$cu
UserRepo$userRepo

Definition at line 71 of file User.php.

71  {
72  if (!strlen($username) || preg_match("/[\\\`,\"\s;]/", $username)) {
73  throw new Exception(static::class . ": invalid username [$username]");
74  }
75 
76  if (!strlen($creditUnion)) {
77  throw new Exception(static::class . ": invalid credit union [$cu]");
78  }
79 
80  if (!$userRepo instanceof UserRepo) {
81  throw new Exception(static::class . ": need instance of UserRepo");
82  }
83  $this->username = $username;
84  $this->creditUnion = $creditUnion;
85  $this->userRepo = $userRepo;
86  $this->Load();
87  }
Load()
Definition: User.php:137

Member Function Documentation

◆ __get()

User::__get ( string  $propertyName)

Magic method returns allowed properties

Parameters
string$propertyName
Returns
mixed|null
Exceptions
Exception

Definition at line 96 of file User.php.

96  {
97  if (in_array($propertyName, array_merge($this->allowedProperties, $this->derivedProperties))) {
98  return $this->data[$propertyName] ?? null;
99  } else {
100  throw new Exception(static::class . ": Property [$propertyName] does not exist.");
101  }
102  }

◆ __isset()

User::__isset ( String  $propertyName)

Magic method to check for existence of a property. Needed for functions like 'empty'

Parameters
String$propertyName
Returns
bool

Definition at line 128 of file User.php.

128  {
129  return !empty($this->data[$propertyName]);
130  }

◆ __set()

User::__set ( string  $propertyName,
string  $value 
)

Magic method sets allowed properties

Parameters
string$propertyName
string$value
Exceptions
Exception

Definition at line 112 of file User.php.

112  {
113  if (in_array($propertyName, array_merge($this->allowedProperties))) {
114  $this->data[$propertyName] = $value;
115  $this->dirtyFields[] = $propertyName;
116  } else {
117  throw new Exception(static::class . ": Property [$propertyName] does not exist.");
118  }
119  }

◆ DecodeMFAJson()

User::DecodeMFAJson ( array  $mfaJson)
private

Convert MFA data into a assoc array with this schema. This structure includes both challenge answer and secure code data. [ mfacount: Number of challenge answers answers: Assoc array of question ids and answers challenge: Active challenge question id. Does not seem to be used anymore authcode: Active secure access code authexpires: Active Secure access code expiration mfadate: Challenge answers save timestamp ]

Parameters
array$mfaJsonArray of challenge questions from database
Returns
array

Definition at line 163 of file User.php.

163  {
164  return [
165  'mfacount' => HCU_array_key_exists('answers', $mfaJson) ? count($mfaJson['answers']) : 0,
166  'answers' => HCU_array_key_exists('answers', $mfaJson) ?? [],
167  'challenge' => HCU_array_key_exists('challenge', $mfaJson) ? intval($mfaJson['challenge']) : 0,
168  'authcode' => HCU_array_key_exists('authcode', $mfaJson) ? strtolower($mfaJson['authcode']) : null,
169  'authexpires' => HCU_array_key_exists('authexpires', $mfaJson) ? intval($mfaJson['authexpires']) : null,
170  'mfadate' => HCU_array_key_exists('mfadate', $mfaJson) ? intval($mfaJson['mfadate']) : 0,
171  ];
172  }

◆ Load()

User::Load ( )
private

Load the user model with data

Exceptions
Exception

Definition at line 137 of file User.php.

137  {
138  $this->data = $this->userRepo->Read($this->username);
139 
140  if (!$this->data) {
141  throw new Exception(static::class . ": Invalid user '$this->username' for credit union {$this->creditUnion}.");
142  }
143  $this->isUserLoaded = true;
144  // Derive further user properties
145  $this->data['mfaquest'] = $this->DecodeMFAJson(HCU_JsonDecode($this->data['mfaquest']));
146  $this->data['freset'] = $this->userflags & static::MEM_FORCE_RESET;
147  }
DecodeMFAJson(array $mfaJson)
Definition: User.php:163

Member Data Documentation

◆ $allowedProperties

User::$allowedProperties
private
Initial value:
= [
'confidence',
'cuuser_group_id',
'email',
'failedremain',
'fchange',
'flog',
'fremain',
'llog',
'mfaquest',
'msg_tx',
'passwd',
'pchange',
'primary_account',
'savecqid',
'user_id',
'user_name',
'userflags',
]

Definition at line 41 of file User.php.

◆ $derivedProperties

User::$derivedProperties
private
Initial value:
= [
'freset',
]

Definition at line 60 of file User.php.


The documentation for this class was generated from the following file: