Skip to content

Commit efbf356

Browse files
committed
Only update the ACL if the user hasn't changed orgs.
1 parent bbcbe5b commit efbf356

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

classes/XDUser.php

+15-3
Original file line numberDiff line numberDiff line change
@@ -2443,11 +2443,16 @@ public static function validateRID($rid)
24432443
public function postLogin() {
24442444
if (!$this->isSticky()) {
24452445
$this->updatePerson();
2446-
// CampusChampionAclUpdater is defined in the xdmod-xsede module.
2447-
if (class_exists('\User\CampusChampionAclUpdater')) {
2446+
$orgHasChanged = $this->synchronizeOrganization();
2447+
// If the user hasn't changed organizations, check if they should
2448+
// be given the Campus Champion ACL (CampusChampionAclUpdater is
2449+
// defined in the xdmod-xsede module).
2450+
if (
2451+
!$orgHasChanged
2452+
&& class_exists('\User\CampusChampionAclUpdater')
2453+
) {
24482454
\User\CampusChampionAclUpdater::update($this);
24492455
}
2450-
$this->synchronizeOrganization();
24512456
}
24522457
$this->currentToken = XDSessionManager::recordLogin($this);
24532458
}
@@ -2461,10 +2466,14 @@ public function postLogin() {
24612466
* to the admin / user notifying them that additional steps will need to be taken before their
24622467
* former level of access is restored.
24632468
*
2469+
* @return bool whether the user's organization had been updated.
24642470
* @throws Exception
24652471
*/
24662472
public function synchronizeOrganization()
24672473
{
2474+
// Temporarily assume the user's organization has not been updated.
2475+
$orgHasChanged = false;
2476+
24682477
// This is pulled from the moddb.Users.organization_id column for this user record.
24692478
$actualOrganization = $this->getOrganizationID();
24702479

@@ -2480,6 +2489,7 @@ public function synchronizeOrganization()
24802489

24812490
// If these don't match then the user's organization has been updated. Steps need to be taken.
24822491
if ($actualOrganization !== $expectedOrganization) {
2492+
$orgHasChanged = true;
24832493
$originalAcls = $this->getAcls(true);
24842494

24852495
// if the user is currently assigned an acl that interacts with XDMoD's centers ( i.e.
@@ -2551,6 +2561,8 @@ public function synchronizeOrganization()
25512561
$this->setOrganizationId($expectedOrganization);
25522562
$this->saveUser();
25532563
}
2564+
2565+
return $orgHasChanged;
25542566
}
25552567

25562568
/**

0 commit comments

Comments
 (0)