Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Log attribute updates #886

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}

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
Loading