Merge pull request #33052 from nextcloud/fix/set-display-name

Do not send display name twice for saving
This commit is contained in:
Joas Schilling 2022-07-06 22:51:06 +02:00 committed by GitHub
commit 744f1dd563
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 3 deletions

View file

@ -837,7 +837,9 @@ class UsersController extends AUserData {
switch ($key) {
case self::USER_FIELD_DISPLAYNAME:
case IAccountManager::PROPERTY_DISPLAYNAME:
$targetUser->setDisplayName($value);
if (!$targetUser->setDisplayName($value)) {
throw new OCSException('Invalid displayname', 102);
}
break;
case self::USER_FIELD_QUOTA:
$quota = $value;

View file

@ -1486,7 +1486,8 @@ class UsersControllerTest extends TestCase {
$targetUser
->expects($this->once())
->method('setDisplayName')
->with('NewDisplayName');
->with('NewDisplayName')
->willReturn(true);
$targetUser
->expects($this->any())
->method('getUID')

View file

@ -128,7 +128,8 @@
_.each(this._inputFields, function(field) {
if (
field === 'avatar' ||
field === 'email'
field === 'email' ||
field === 'displayname'
) {
return;
}

View file

@ -215,6 +215,10 @@ class Database extends ABackend implements
* Change the display name of a user
*/
public function setDisplayName(string $uid, string $displayName): bool {
if (mb_strlen($displayName) > 64) {
return false;
}
$this->fixDI();
if ($this->userExists($uid)) {