|
9 | 9 |
|
10 | 10 | use InvalidArgumentException; |
11 | 11 | use OC\Accounts\AccountManager; |
12 | | -use OCA\UserOIDC\AppInfo\Application; |
13 | 12 | use OCA\UserOIDC\Db\UserMapper; |
14 | 13 | use OCA\UserOIDC\Event\AttributeMappedEvent; |
15 | 14 | use OCP\Accounts\IAccountManager; |
@@ -176,29 +175,10 @@ public function provisionUser(string $tokenUserId, int $providerId, object $idTo |
176 | 175 | if ($event->hasValue() && $event->getValue() !== null && $event->getValue() !== '') { |
177 | 176 | $oidcGssUserData[$displaynameAttribute] = $event->getValue(); |
178 | 177 | $newDisplayName = $event->getValue(); |
179 | | - if ($existingLocalUser === null) { |
180 | | - $oldDisplayName = $backendUser->getDisplayName(); |
181 | | - if ($newDisplayName !== $oldDisplayName) { |
182 | | - $backendUser->setDisplayName($newDisplayName); |
183 | | - $this->userMapper->update($backendUser); |
184 | | - } |
185 | | - // 2 reasons why we should update the display name: It does not match the one |
186 | | - // - of our backend |
187 | | - // - returned by the user manager (outdated one before the fix in https://github.com/nextcloud/user_oidc/pull/530) |
188 | | - if ($newDisplayName !== $oldDisplayName || $newDisplayName !== $user->getDisplayName()) { |
189 | | - $this->eventDispatcher->dispatchTyped(new UserChangedEvent($user, 'displayName', $newDisplayName, $oldDisplayName)); |
190 | | - } |
191 | | - } else { |
192 | | - $oldDisplayName = $user->getDisplayName(); |
193 | | - if ($newDisplayName !== $oldDisplayName) { |
194 | | - $user->setDisplayName($newDisplayName); |
195 | | - if ($user->getBackendClassName() === Application::APP_ID) { |
196 | | - $backendUser = $this->userMapper->getOrCreate($providerId, $user->getUID()); |
197 | | - $backendUser->setDisplayName($newDisplayName); |
198 | | - $this->userMapper->update($backendUser); |
199 | | - } |
200 | | - $this->eventDispatcher->dispatchTyped(new UserChangedEvent($user, 'displayName', $newDisplayName, $oldDisplayName)); |
201 | | - } |
| 178 | + $oldDisplayName = $user->getDisplayName(); |
| 179 | + if ($newDisplayName !== $oldDisplayName) { |
| 180 | + $user->setDisplayName($newDisplayName); |
| 181 | + $this->eventDispatcher->dispatchTyped(new UserChangedEvent($user, 'displayName', $newDisplayName, $oldDisplayName)); |
202 | 182 | } |
203 | 183 | } |
204 | 184 |
|
|
0 commit comments