diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 7f23926926..ee939f587b 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -335,7 +335,7 @@ class UsersController extends AUserData { } // Send new user mail only if a mail is set - if ($email !== '') { + if ($email !== '' && $this->config->getAppValue('core', 'newUser.sendEmail', 'yes') === 'yes') { $newUser->setEMailAddress($email); try { $emailTemplate = $this->newUserMailHelper->generateTemplate($newUser, $generatePasswordResetToken); diff --git a/apps/settings/appinfo/routes.php b/apps/settings/appinfo/routes.php index 45f0cc2571..89b6c86993 100644 --- a/apps/settings/appinfo/routes.php +++ b/apps/settings/appinfo/routes.php @@ -70,6 +70,7 @@ $application->registerRoutes($this, [ ['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'], ['name' => 'Users#usersList', 'url' => '/settings/users', 'verb' => 'GET'], ['name' => 'Users#usersListByGroup', 'url' => '/settings/users/{group}', 'verb' => 'GET', 'requirements' => ['group' => '.+']], + ['name' => 'Users#setPreference', 'url' => '/settings/users/preferences/{key}', 'verb' => 'POST'], ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'], ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'], ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'], diff --git a/apps/settings/js/vue-0.js b/apps/settings/js/vue-0.js index 6c6d69b577..8b9bebc4c5 100644 Binary files a/apps/settings/js/vue-0.js and b/apps/settings/js/vue-0.js differ diff --git a/apps/settings/js/vue-0.js.map b/apps/settings/js/vue-0.js.map index ad3d1b2823..26f2c76258 100644 Binary files a/apps/settings/js/vue-0.js.map and b/apps/settings/js/vue-0.js.map differ diff --git a/apps/settings/js/vue-5.js b/apps/settings/js/vue-5.js index cd1bcb6bfc..813f2ee099 100644 Binary files a/apps/settings/js/vue-5.js and b/apps/settings/js/vue-5.js differ diff --git a/apps/settings/js/vue-5.js.map b/apps/settings/js/vue-5.js.map index 898b8e2f08..a880696a99 100644 Binary files a/apps/settings/js/vue-5.js.map and b/apps/settings/js/vue-5.js.map differ diff --git a/apps/settings/js/vue-7.js b/apps/settings/js/vue-7.js index 468a4e7a6d..6d7c55bcae 100644 Binary files a/apps/settings/js/vue-7.js and b/apps/settings/js/vue-7.js differ diff --git a/apps/settings/js/vue-7.js.map b/apps/settings/js/vue-7.js.map index 755b16acdf..709d9faf94 100644 Binary files a/apps/settings/js/vue-7.js.map and b/apps/settings/js/vue-7.js.map differ diff --git a/apps/settings/js/vue-settings-admin-security.js b/apps/settings/js/vue-settings-admin-security.js index d551a82460..65082ff9d7 100644 Binary files a/apps/settings/js/vue-settings-admin-security.js and b/apps/settings/js/vue-settings-admin-security.js differ diff --git a/apps/settings/js/vue-settings-admin-security.js.map b/apps/settings/js/vue-settings-admin-security.js.map index d675fd6284..464b970a7a 100644 Binary files a/apps/settings/js/vue-settings-admin-security.js.map and b/apps/settings/js/vue-settings-admin-security.js.map differ diff --git a/apps/settings/js/vue-settings-apps-users-management.js b/apps/settings/js/vue-settings-apps-users-management.js index 7c29df6f9b..a3e723a887 100644 Binary files a/apps/settings/js/vue-settings-apps-users-management.js and b/apps/settings/js/vue-settings-apps-users-management.js differ diff --git a/apps/settings/js/vue-settings-apps-users-management.js.map b/apps/settings/js/vue-settings-apps-users-management.js.map index a2eb9a54d3..4e5a37f099 100644 Binary files a/apps/settings/js/vue-settings-apps-users-management.js.map and b/apps/settings/js/vue-settings-apps-users-management.js.map differ diff --git a/apps/settings/js/vue-settings-personal-security.js b/apps/settings/js/vue-settings-personal-security.js index 8984f8a198..b2d41e2561 100644 Binary files a/apps/settings/js/vue-settings-personal-security.js and b/apps/settings/js/vue-settings-personal-security.js differ diff --git a/apps/settings/js/vue-settings-personal-security.js.map b/apps/settings/js/vue-settings-personal-security.js.map index 3e20e96153..13efe2fb6f 100644 Binary files a/apps/settings/js/vue-settings-personal-security.js.map and b/apps/settings/js/vue-settings-personal-security.js.map differ diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 2c20ce36ca..cfbe35eb20 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -35,11 +35,13 @@ use OC\AppFramework\Http; use OC\Encryption\Exceptions\ModuleDoesNotExistsException; use OC\ForbiddenException; use OC\Security\IdentityProof\Manager; +use OCA\Settings\AppInfo\Application; use OCA\Settings\BackgroundJobs\VerifyUserData; use OCA\User_LDAP\User_Proxy; use OCP\App\IAppManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\TemplateResponse; use OCP\BackgroundJob\IJobList; use OCP\Encryption\IManager; @@ -52,6 +54,7 @@ use OCP\IUserManager; use OCP\IUserSession; use OCP\L10N\IFactory; use OCP\Mail\IMailer; +use function in_array; class UsersController extends Controller { /** @var IUserManager */ @@ -238,10 +241,28 @@ class UsersController extends Controller { $serverData['canChangePassword'] = $canChangePassword; $serverData['newUserGenerateUserID'] = $this->config->getAppValue('core', 'newUser.generateUserID', 'no') === 'yes'; $serverData['newUserRequireEmail'] = $this->config->getAppValue('core', 'newUser.requireEmail', 'no') === 'yes'; + $serverData['newUserSendEmail'] = $this->config->getAppValue('core', 'newUser.sendEmail', 'yes') === 'yes'; return new TemplateResponse('settings', 'settings-vue', ['serverData' => $serverData]); } + /** + * @param string $key + * @param string $value + * + * @return JSONResponse + */ + public function setPreference(string $key, string $value): JSONResponse { + $allowed = ['newUser.sendEmail']; + if (!in_array($key, $allowed, true)) { + return new JSONResponse([], Http::STATUS_FORBIDDEN); + } + + $this->config->setAppValue('core', $key, $value); + + return new JSONResponse([]); + } + /** * Parse the app value for quota_present * diff --git a/apps/settings/src/views/Users.vue b/apps/settings/src/views/Users.vue index 01fb9a9b48..284317f258 100644 --- a/apps/settings/src/views/Users.vue +++ b/apps/settings/src/views/Users.vue @@ -135,6 +135,14 @@ class="checkbox"> +
+ + +
@@ -156,7 +164,9 @@ import AppNavigationCounter from '@nextcloud/vue/dist/Components/AppNavigationCo import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem' import AppNavigationNew from '@nextcloud/vue/dist/Components/AppNavigationNew' import AppNavigationSettings from '@nextcloud/vue/dist/Components/AppNavigationSettings' +import axios from '@nextcloud/axios' import Content from '@nextcloud/vue/dist/Components/Content' +import { generateUrl } from '@nextcloud/router' import Multiselect from '@nextcloud/vue/dist/Components/Multiselect' import Vue from 'vue' import VueLocalStorage from 'vue-localstorage' @@ -194,6 +204,7 @@ export default { selectedQuota: false, externalActions: [], loadingAddGroup: false, + loadingSendMail: false, showConfig: { showStoragePath: false, showUserBackend: false, @@ -276,6 +287,26 @@ export default { }, + sendWelcomeMail: { + get() { + return this.settings.newUserSendEmail + }, + async set(value) { + try { + this.loadingSendMail = true + this.$store.commit('setServerData', { + ...this.settings, + newUserSendEmail: value, + }) + await axios.post(generateUrl(`/settings/users/preferences/newUser.sendEmail`), { value: value ? 'yes' : 'no' }) + } catch (e) { + console.error('could not update newUser.sendEmail preference: ' + e.message, e) + } finally { + this.loadingSendMail = false + } + }, + }, + groupList() { const groups = Array.isArray(this.groups) ? this.groups : []