Skip to content

Commit

Permalink
fix: Log attribute updates
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Sep 17, 2024
1 parent 0130d26 commit 6296904
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/UserBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,23 +564,52 @@ public function updateAttributes(string $uid, array $attributes): void {
}

if ($user !== null) {
$this->logger->debug('Updating attributes for existing user', ['app' => 'user_saml', 'user' => $user->getUID()]);
$currentEmail = (string)(method_exists($user, 'getSystemEMailAddress') ? $user->getSystemEMailAddress() : $user->getEMailAddress());

Check failure on line 568 in lib/UserBackend.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

RedundantCondition

lib/UserBackend.php:568:29: RedundantCondition: Type OCP\IUser for $user is always method-exists-getSystemEMailAddress (see https://psalm.dev/122)
if ($newEmail !== null
&& $currentEmail !== $newEmail) {
$user->setEMailAddress($newEmail);
$this->logger->debug('Email address updated', ['app' => 'user_saml', 'user' => $user->getUID()]);
} else {
$this->logger->debug('Email address not updated', [
'app' => 'user_saml',
'user' => $user->getUID(),
'currentEmail' => $currentEmail,
'newEmail' => $newEmail,
]);
}
$currentDisplayname = $this->getDisplayName($uid);
if ($newDisplayname !== null
&& $currentDisplayname !== $newDisplayname) {
$this->setDisplayName($uid, $newDisplayname);
$this->logger->debug('Display name updated', ['app' => 'user_saml', 'user' => $user->getUID()]);
$this->eventDispatcher->dispatchTyped(new UserChangedEvent($user, 'displayName', $newDisplayname, $currentDisplayname));
$this->logger->debug('Display name update event dispatched', ['app' => 'user_saml', 'user' => $user->getUID()]);
} else {
$this->logger->debug('Display name not updated', [
'app' => 'user_saml',
'user' => $user->getUID(),
'newDisplayname' => $newDisplayname,
'currentDisplayname' => $currentDisplayname,
]);
}

if ($newQuota !== null) {
$user->setQuota($newQuota);
$this->logger->debug('Quota updated', ['app' => 'user_saml', 'user' => $user->getUID()]);
} else {
$this->logger->debug('Quota not updated', [
'app' => 'user_saml',
'user' => $user->getUID(),
]);
}

$this->groupManager->handleIncomingGroups($user, $newGroups ?? []);
$this->logger->debug('Incoming groups updated', [
'app' => 'user_saml',
'user' => $user->getUID(),
'groups' => $newGroups,
]);
}
}

Expand Down

0 comments on commit 6296904

Please sign in to comment.