Skip to content

Commit b8203dd

Browse files
committed
refactor: add migration for email setting
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent c79f082 commit b8203dd

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed

apps/provisioning_api/lib/Controller/UsersController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ public function getEditableFieldsForUser(string $userId): DataResponse {
751751
}
752752

753753
// Fallback to display name value to avoid changing behavior with the new option.
754-
if ($this->config->getSystemValue('allow_user_to_change_email', $allowDisplayNameChange)) {
754+
if ($this->config->getSystemValue('allow_user_to_change_email', true)) {
755755
$permittedFields[] = IAccountManager::PROPERTY_EMAIL;
756756
}
757757

@@ -911,8 +911,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
911911
$permittedFields[] = IAccountManager::PROPERTY_DISPLAYNAME;
912912
}
913913

914-
// Fallback to display name value to avoid changing behavior with the new option.
915-
if ($this->config->getSystemValue('allow_user_to_change_email', $allowDisplayNameChange)) {
914+
if ($this->config->getSystemValue('allow_user_to_change_email', true)) {
916915
$permittedFields[] = IAccountManager::PROPERTY_EMAIL;
917916
}
918917

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/**
4+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
5+
* SPDX-License-Identifier: AGPL-3.0-or-later
6+
*/
7+
namespace OC\Core\Migrations;
8+
9+
use OCP\IConfig;
10+
use OCP\Migration\IOutput;
11+
use OCP\Migration\SimpleMigrationStep;
12+
13+
/**
14+
* Add `allow_user_to_change_email` system config
15+
*/
16+
class Version32000Date20250402182800 extends SimpleMigrationStep {
17+
18+
public function __construct(
19+
private IConfig $config,
20+
) {
21+
}
22+
23+
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
24+
$allowDisplayName = $this->config->getSystemValue('allow_user_to_change_display_name', null);
25+
$allowEmail = $this->config->getSystemValue('allow_user_to_change_email', null);
26+
27+
// if displayname was set, but not the email setting, then set the email setting to the same as the email setting
28+
if ($allowDisplayName !== null && $allowEmail === null) {
29+
$this->config->setSystemValue('allow_user_to_change_email', $allowDisplayName === true);
30+
}
31+
}
32+
33+
}

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,7 @@
13771377
'OC\\Core\\Migrations\\Version30000Date20240814180800' => $baseDir . '/core/Migrations/Version30000Date20240814180800.php',
13781378
'OC\\Core\\Migrations\\Version30000Date20240815080800' => $baseDir . '/core/Migrations/Version30000Date20240815080800.php',
13791379
'OC\\Core\\Migrations\\Version30000Date20240906095113' => $baseDir . '/core/Migrations/Version30000Date20240906095113.php',
1380+
'OC\\Core\\Migrations\\Version32000Date20250402182800' => $baseDir . '/core/Migrations/Version32000Date20250402182800.php',
13801381
'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
13811382
'OC\\Core\\ResponseDefinitions' => $baseDir . '/core/ResponseDefinitions.php',
13821383
'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
14101410
'OC\\Core\\Migrations\\Version30000Date20240814180800' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240814180800.php',
14111411
'OC\\Core\\Migrations\\Version30000Date20240815080800' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240815080800.php',
14121412
'OC\\Core\\Migrations\\Version30000Date20240906095113' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240906095113.php',
1413+
'OC\\Core\\Migrations\\Version32000Date20250402182800' => __DIR__ . '/../../..' . '/core/Migrations/Version32000Date20250402182800.php',
14131414
'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php',
14141415
'OC\\Core\\ResponseDefinitions' => __DIR__ . '/../../..' . '/core/ResponseDefinitions.php',
14151416
'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php',

lib/private/User/User.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,7 @@ public function canChangeDisplayName() {
429429
}
430430

431431
public function canChangeEmail(): bool {
432-
// Fallback to display name value to avoid changing behavior with the new option.
433-
return $this->config->getSystemValueBool('allow_user_to_change_email', $this->config->getSystemValueBool('allow_user_to_change_display_name', true));
432+
return $this->config->getSystemValueBool('allow_user_to_change_email', true);
434433
}
435434

436435
/**

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// between betas, final and RCs. This is _not_ the public version number. Reset minor/patch level
1010
// when updating major/minor version number.
1111

12-
$OC_Version = [30, 0, 8, 1];
12+
$OC_Version = [30, 0, 8, 2];
1313

1414
// The human-readable string
1515
$OC_VersionString = '30.0.8';

0 commit comments

Comments
 (0)