Skip to content

Commit f0afa80

Browse files
committed
prevent access to user attributes when they might not be defined
1 parent 796ee0d commit f0afa80

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

resources/lib/UnityUser.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public function exists()
176176
*/
177177
public function getUID()
178178
{
179+
assert($this->exists());
179180
return $this->uid;
180181
}
181182

@@ -189,6 +190,7 @@ public function setOrg($org)
189190

190191
public function getOrg($ignorecache = false)
191192
{
193+
assert($this->exists());
192194
if (!$ignorecache) {
193195
$cached_val = $this->REDIS->getCache($this->getUID(), "org");
194196
if (!is_null($cached_val)) {
@@ -238,6 +240,7 @@ public function setFirstname($firstname, $operator = null)
238240
*/
239241
public function getFirstname($ignorecache = false)
240242
{
243+
assert($this->exists());
241244
if (!$ignorecache) {
242245
$cached_val = $this->REDIS->getCache($this->getUID(), "firstname");
243246
if (!is_null($cached_val)) {
@@ -287,6 +290,7 @@ public function setLastname($lastname, $operator = null)
287290
*/
288291
public function getLastname($ignorecache = false)
289292
{
293+
assert($this->exists());
290294
if (!$ignorecache) {
291295
$cached_val = $this->REDIS->getCache($this->getUID(), "lastname");
292296
if (!is_null($cached_val)) {
@@ -309,6 +313,7 @@ public function getLastname($ignorecache = false)
309313

310314
public function getFullname()
311315
{
316+
assert($this->exists());
312317
return $this->getFirstname() . " " . $this->getLastname();
313318
}
314319

@@ -341,6 +346,7 @@ public function setMail($email, $operator = null)
341346
*/
342347
public function getMail($ignorecache = false)
343348
{
349+
assert($this->exists());
344350
if (!$ignorecache) {
345351
$cached_val = $this->REDIS->getCache($this->getUID(), "mail");
346352
if (!is_null($cached_val)) {
@@ -404,6 +410,7 @@ public function setSSHKeys($keys, $operator = null, $send_mail = true)
404410
*/
405411
public function getSSHKeys($ignorecache = false)
406412
{
413+
assert($this->exists());
407414
if (!$ignorecache) {
408415
$cached_val = $this->REDIS->getCache($this->getUID(), "sshkeys");
409416
if (!is_null($cached_val)) {
@@ -480,6 +487,7 @@ public function setLoginShell($shell, $operator = null, $send_mail = true)
480487
*/
481488
public function getLoginShell($ignorecache = false)
482489
{
490+
assert($this->exists());
483491
if (!$ignorecache) {
484492
$cached_val = $this->REDIS->getCache($this->getUID(), "loginshell");
485493
if (!is_null($cached_val)) {
@@ -528,6 +536,7 @@ public function setHomeDir($home, $operator = null)
528536
*/
529537
public function getHomeDir($ignorecache = false)
530538
{
539+
assert($this->exists());
531540
if (!$ignorecache) {
532541
$cached_val = $this->REDIS->getCache($this->getUID(), "homedir");
533542
if (!is_null($cached_val)) {

0 commit comments

Comments
 (0)