From 0f9838cee5c76b254e9be10b5e0de6ec4dc58029 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 19 Sep 2024 13:37:11 +0000 Subject: [PATCH] ensure data is present before using it in Shib auth plugin, fixes #4616 Closes #4616 Merge request studip/studip!3429 --- lib/classes/auth_plugins/StudipAuthShib.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/classes/auth_plugins/StudipAuthShib.php b/lib/classes/auth_plugins/StudipAuthShib.php index 5548e92c14d..f18f0c1e5e8 100644 --- a/lib/classes/auth_plugins/StudipAuthShib.php +++ b/lib/classes/auth_plugins/StudipAuthShib.php @@ -42,12 +42,14 @@ class StudipAuthShib extends StudipAuthSSO $this->userdata = json_decode($auth, true); - if ($this->username_attribute !== 'username') { - $this->userdata['username'] = $this->userdata[$this->username_attribute]; - } - if (isset($this->local_domain)) { - $this->userdata['username'] = - str_replace('@' . $this->local_domain, '', $this->userdata['username']); + if ($this->userdata) { + if ($this->username_attribute !== 'username') { + $this->userdata['username'] = $this->userdata[$this->username_attribute]; + } + if (isset($this->local_domain)) { + $this->userdata['username'] = + str_replace('@' . $this->local_domain, '', $this->userdata['username']); + } } } } -- GitLab