diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2025-09-01 13:59:14 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2025-09-01 14:13:06 +0200 |
| commit | 82fdc5887a593a2d1ab325cdca2ec9d9f16e7602 (patch) | |
| tree | af5146b0b1a26793bfc5fc9b2b5efbd09d39c26a /lib/classes/auth_plugins/StudipAuthAbstract.class.php | |
| parent | 5cea01e912ccb652097c7b03aae01674ed3ef065 (diff) | |
don't sync all domains (if not configured) with shibboleth login, fixes #2055
Closes #2055
Merge request studip/studip!3515
Diffstat (limited to 'lib/classes/auth_plugins/StudipAuthAbstract.class.php')
| -rw-r--r-- | lib/classes/auth_plugins/StudipAuthAbstract.class.php | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/classes/auth_plugins/StudipAuthAbstract.class.php b/lib/classes/auth_plugins/StudipAuthAbstract.class.php index 1b94de9..984da41 100644 --- a/lib/classes/auth_plugins/StudipAuthAbstract.class.php +++ b/lib/classes/auth_plugins/StudipAuthAbstract.class.php @@ -56,11 +56,14 @@ class StudipAuthAbstract /** * array of user domains to assign to each user, can be set in local.inc - * - * @access public - * @var array $user_domains */ - public $user_domains; + public ?array $user_domains = null; + + /** + * Flag that decides whether all domains should be synced or if only new + * ones should be added. + */ + public bool $sync_all_domains = true; /** * associative array with mapping for database fields @@ -381,10 +384,18 @@ class StudipAuthAbstract $uid = $user->id; if (isset($user_domains)) { $old_domains = UserDomain::getUserDomainsForUser($uid); - - foreach ($old_domains as $domain) { - if (!in_array($domain->id, $user_domains)) { - $domain->removeUser($uid); + $old_domain_ids = array_map( + function (UserDomain $domain) { + return $domain->id; + }, + $old_domains + ); + + if ($this->sync_all_domains) { + foreach ($old_domains as $domain) { + if (!in_array($domain->id, $user_domains)) { + $domain->removeUser($uid); + } } } @@ -396,7 +407,7 @@ class StudipAuthAbstract $domain->store(); } - if (!in_array($domain, $old_domains)) { + if (!in_array($domain->id, $old_domain_ids)) { $domain->addUser($uid); } } |
