Skip to content

Commit f1e3312

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

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
@@ -717,7 +717,7 @@ public function getEditableFieldsForUser(string $userId): DataResponse {
717717
}
718718

719719
// Fallback to display name value to avoid changing behavior with the new option.
720-
if ($this->config->getSystemValue('allow_user_to_change_email', $allowDisplayNameChange)) {
720+
if ($this->config->getSystemValue('allow_user_to_change_email', true)) {
721721
$permittedFields[] = IAccountManager::PROPERTY_EMAIL;
722722
}
723723

@@ -873,8 +873,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
873873
$permittedFields[] = IAccountManager::PROPERTY_DISPLAYNAME;
874874
}
875875

876-
// Fallback to display name value to avoid changing behavior with the new option.
877-
if ($this->config->getSystemValue('allow_user_to_change_email', $allowDisplayNameChange)) {
876+
if ($this->config->getSystemValue('allow_user_to_change_email', true)) {
878877
$permittedFields[] = IAccountManager::PROPERTY_EMAIL;
879878
}
880879

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
@@ -1284,6 +1284,7 @@
12841284
'OC\\Core\\Migrations\\Version29000Date20240124132202' => $baseDir . '/core/Migrations/Version29000Date20240124132202.php',
12851285
'OC\\Core\\Migrations\\Version29000Date20240131122720' => $baseDir . '/core/Migrations/Version29000Date20240131122720.php',
12861286
'OC\\Core\\Migrations\\Version30000Date20240814180800' => $baseDir . '/core/Migrations/Version30000Date20240814180800.php',
1287+
'OC\\Core\\Migrations\\Version32000Date20250402182800' => $baseDir . '/core/Migrations/Version32000Date20250402182800.php',
12871288
'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
12881289
'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php',
12891290
'OC\\DB\\Adapter' => $baseDir . '/lib/private/DB/Adapter.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
13171317
'OC\\Core\\Migrations\\Version29000Date20240124132202' => __DIR__ . '/../../..' . '/core/Migrations/Version29000Date20240124132202.php',
13181318
'OC\\Core\\Migrations\\Version29000Date20240131122720' => __DIR__ . '/../../..' . '/core/Migrations/Version29000Date20240131122720.php',
13191319
'OC\\Core\\Migrations\\Version30000Date20240814180800' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240814180800.php',
1320+
'OC\\Core\\Migrations\\Version32000Date20250402182800' => __DIR__ . '/../../..' . '/core/Migrations/Version32000Date20250402182800.php',
13201321
'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php',
13211322
'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php',
13221323
'OC\\DB\\Adapter' => __DIR__ . '/../../..' . '/lib/private/DB/Adapter.php',

lib/private/User/User.php

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

443443
public function canChangeEmail(): bool {
444-
// Fallback to display name value to avoid changing behavior with the new option.
445-
return $this->config->getSystemValueBool('allow_user_to_change_email', $this->config->getSystemValueBool('allow_user_to_change_display_name', true));
444+
return $this->config->getSystemValueBool('allow_user_to_change_email', true);
446445
}
447446

448447
/**

version.php

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

33-
$OC_Version = [29, 0, 14, 1];
33+
$OC_Version = [29, 0, 14, 2];
3434

3535
// The human-readable string
3636
$OC_VersionString = '29.0.14';

0 commit comments

Comments
 (0)