Skip to content
Snippets Groups Projects
Unverified Commit d47daefe authored by Christoph Wurst's avatar Christoph Wurst
Browse files

Revive the "send email to new users" toggle for the user form

parent 0f08acfe
No related branches found
No related tags found
No related merge requests found
Showing
with 54 additions and 1 deletion
...@@ -335,7 +335,7 @@ class UsersController extends AUserData { ...@@ -335,7 +335,7 @@ class UsersController extends AUserData {
} }
// Send new user mail only if a mail is set // 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); $newUser->setEMailAddress($email);
try { try {
$emailTemplate = $this->newUserMailHelper->generateTemplate($newUser, $generatePasswordResetToken); $emailTemplate = $this->newUserMailHelper->generateTemplate($newUser, $generatePasswordResetToken);
......
...@@ -70,6 +70,7 @@ $application->registerRoutes($this, [ ...@@ -70,6 +70,7 @@ $application->registerRoutes($this, [
['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'], ['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'],
['name' => 'Users#usersList', 'url' => '/settings/users', 'verb' => 'GET'], ['name' => 'Users#usersList', 'url' => '/settings/users', 'verb' => 'GET'],
['name' => 'Users#usersListByGroup', 'url' => '/settings/users/{group}', 'verb' => 'GET', 'requirements' => ['group' => '.+']], ['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#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'],
['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'], ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'],
['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'], ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'],
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -35,11 +35,13 @@ use OC\AppFramework\Http; ...@@ -35,11 +35,13 @@ use OC\AppFramework\Http;
use OC\Encryption\Exceptions\ModuleDoesNotExistsException; use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
use OC\ForbiddenException; use OC\ForbiddenException;
use OC\Security\IdentityProof\Manager; use OC\Security\IdentityProof\Manager;
use OCA\Settings\AppInfo\Application;
use OCA\Settings\BackgroundJobs\VerifyUserData; use OCA\Settings\BackgroundJobs\VerifyUserData;
use OCA\User_LDAP\User_Proxy; use OCA\User_LDAP\User_Proxy;
use OCP\App\IAppManager; use OCP\App\IAppManager;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\BackgroundJob\IJobList; use OCP\BackgroundJob\IJobList;
use OCP\Encryption\IManager; use OCP\Encryption\IManager;
...@@ -52,6 +54,7 @@ use OCP\IUserManager; ...@@ -52,6 +54,7 @@ use OCP\IUserManager;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\L10N\IFactory; use OCP\L10N\IFactory;
use OCP\Mail\IMailer; use OCP\Mail\IMailer;
use function in_array;
class UsersController extends Controller { class UsersController extends Controller {
/** @var IUserManager */ /** @var IUserManager */
...@@ -238,10 +241,28 @@ class UsersController extends Controller { ...@@ -238,10 +241,28 @@ class UsersController extends Controller {
$serverData['canChangePassword'] = $canChangePassword; $serverData['canChangePassword'] = $canChangePassword;
$serverData['newUserGenerateUserID'] = $this->config->getAppValue('core', 'newUser.generateUserID', 'no') === 'yes'; $serverData['newUserGenerateUserID'] = $this->config->getAppValue('core', 'newUser.generateUserID', 'no') === 'yes';
$serverData['newUserRequireEmail'] = $this->config->getAppValue('core', 'newUser.requireEmail', '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]); 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 * Parse the app value for quota_present
* *
......
...@@ -135,6 +135,14 @@ ...@@ -135,6 +135,14 @@
class="checkbox"> class="checkbox">
<label for="showStoragePath">{{ t('settings', 'Show storage path') }}</label> <label for="showStoragePath">{{ t('settings', 'Show storage path') }}</label>
</div> </div>
<div>
<input id="sendWelcomeMail"
v-model="sendWelcomeMail"
:disabled="loadingSendMail"
type="checkbox"
class="checkbox">
<label for="sendWelcomeMail">{{ t('settings', 'Send email to new user') }}</label>
</div>
</AppNavigationSettings> </AppNavigationSettings>
</AppNavigation> </AppNavigation>
<AppContent> <AppContent>
...@@ -156,7 +164,9 @@ import AppNavigationCounter from '@nextcloud/vue/dist/Components/AppNavigationCo ...@@ -156,7 +164,9 @@ import AppNavigationCounter from '@nextcloud/vue/dist/Components/AppNavigationCo
import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem' import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem'
import AppNavigationNew from '@nextcloud/vue/dist/Components/AppNavigationNew' import AppNavigationNew from '@nextcloud/vue/dist/Components/AppNavigationNew'
import AppNavigationSettings from '@nextcloud/vue/dist/Components/AppNavigationSettings' import AppNavigationSettings from '@nextcloud/vue/dist/Components/AppNavigationSettings'
import axios from '@nextcloud/axios'
import Content from '@nextcloud/vue/dist/Components/Content' import Content from '@nextcloud/vue/dist/Components/Content'
import { generateUrl } from '@nextcloud/router'
import Multiselect from '@nextcloud/vue/dist/Components/Multiselect' import Multiselect from '@nextcloud/vue/dist/Components/Multiselect'
import Vue from 'vue' import Vue from 'vue'
import VueLocalStorage from 'vue-localstorage' import VueLocalStorage from 'vue-localstorage'
...@@ -194,6 +204,7 @@ export default { ...@@ -194,6 +204,7 @@ export default {
selectedQuota: false, selectedQuota: false,
externalActions: [], externalActions: [],
loadingAddGroup: false, loadingAddGroup: false,
loadingSendMail: false,
showConfig: { showConfig: {
showStoragePath: false, showStoragePath: false,
showUserBackend: false, showUserBackend: false,
...@@ -276,6 +287,26 @@ export default { ...@@ -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() { groupList() {
const groups = Array.isArray(this.groups) ? this.groups : [] const groups = Array.isArray(this.groups) ? this.groups : []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment