Merge pull request #19703 from nextcloud/feature/revive-send-welcome-email-toggle-stable17
[stable17] Revive the "send email to new users" toggle for the user form
This commit is contained in:
commit
369e05889c
8 changed files with 69 additions and 17 deletions
|
@ -328,7 +328,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);
|
||||||
|
|
|
@ -44,10 +44,12 @@ 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\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;
|
||||||
|
@ -61,6 +63,7 @@ use OCP\IUserSession;
|
||||||
use OCP\L10N\IFactory;
|
use OCP\L10N\IFactory;
|
||||||
use OCP\Mail\IMailer;
|
use OCP\Mail\IMailer;
|
||||||
use OC\Settings\BackgroundJobs\VerifyUserData;
|
use OC\Settings\BackgroundJobs\VerifyUserData;
|
||||||
|
use function in_array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package OC\Settings\Controller
|
* @package OC\Settings\Controller
|
||||||
|
@ -255,10 +258,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([]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if the admin can change the users password
|
* check if the admin can change the users password
|
||||||
*
|
*
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -69,6 +69,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'],
|
||||||
|
|
|
@ -54,6 +54,14 @@
|
||||||
<input type="checkbox" id="showStoragePath" class="checkbox" v-model="showStoragePath">
|
<input type="checkbox" id="showStoragePath" class="checkbox" v-model="showStoragePath">
|
||||||
<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>
|
||||||
|
@ -63,6 +71,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import axios from '@nextcloud/axios'
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import VueLocalStorage from 'vue-localstorage'
|
import VueLocalStorage from 'vue-localstorage'
|
||||||
import {
|
import {
|
||||||
|
@ -122,6 +131,7 @@ export default {
|
||||||
externalActions: [],
|
externalActions: [],
|
||||||
showAddGroupEntry: false,
|
showAddGroupEntry: false,
|
||||||
loadingAddGroup: false,
|
loadingAddGroup: false,
|
||||||
|
loadingSendMail: false,
|
||||||
showConfig: {
|
showConfig: {
|
||||||
showStoragePath: false,
|
showStoragePath: false,
|
||||||
showUserBackend: false,
|
showUserBackend: false,
|
||||||
|
@ -315,6 +325,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(OC.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
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
// BUILD APP NAVIGATION MENU OBJECT
|
// BUILD APP NAVIGATION MENU OBJECT
|
||||||
menu() {
|
menu() {
|
||||||
// Data provided php side
|
// Data provided php side
|
||||||
|
|
Loading…
Reference in a new issue