aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/auth_plugins/StudipAuthAbstract.class.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2025-09-01 13:59:14 +0200
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2025-09-01 14:13:04 +0200
commit872e1ab3316b63b0b6e19b34647c29a7ae9d76f6 (patch)
tree5386d795fd44d6b0ce4f68c6284139ad0ce51117 /lib/classes/auth_plugins/StudipAuthAbstract.class.php
parenteb47fd27fea403bbad268b6e0a2d30f4f4c8f5bd (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.php29
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 623f067..f72b9f8 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
@@ -421,10 +424,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);
+ }
}
}
@@ -436,7 +447,7 @@ class StudipAuthAbstract
$domain->store();
}
- if (!in_array($domain, $old_domains)) {
+ if (!in_array($domain->id, $old_domain_ids)) {
$domain->addUser($uid);
}
}