Merge pull request #19664 from nextcloud/feature/revive-send-welcome-email-toggle

Revive the "send email to new users" toggle for the user form
This commit is contained in:
Christoph Wurst 2020-02-28 17:11:12 +01:00 committed by GitHub
commit 0cb00912ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 54 additions and 1 deletions

View file

@ -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);

View file

@ -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'],

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -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
*

View file

@ -135,6 +135,14 @@
class="checkbox">
<label for="showStoragePath">{{ t('settings', 'Show storage path') }}</label>
</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>
</AppNavigation>
<AppContent>
@ -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 : []