diff options
Diffstat (limited to 'apps/settings/lib/Controller/UsersController.php')
-rw-r--r-- | apps/settings/lib/Controller/UsersController.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 28fdead4abe..107f047aa30 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -68,11 +68,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; @@ -85,6 +87,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 */ @@ -276,11 +279,29 @@ 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([]); + } + + /** * check if the admin can change the users password * * The admin can change the passwords if: |