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
|
||||
if ($email !== '') {
|
||||
if ($email !== '' && $this->config->getAppValue('core', 'newUser.sendEmail', 'yes') === 'yes') {
|
||||
$newUser->setEMailAddress($email);
|
||||
try {
|
||||
$emailTemplate = $this->newUserMailHelper->generateTemplate($newUser, $generatePasswordResetToken);
|
||||
|
|
|
@ -44,10 +44,12 @@ use OC\AppFramework\Http;
|
|||
use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
|
||||
use OC\ForbiddenException;
|
||||
use OC\Security\IdentityProof\Manager;
|
||||
use OCA\Settings\AppInfo\Application;
|
||||
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;
|
||||
|
@ -61,6 +63,7 @@ use OCP\IUserSession;
|
|||
use OCP\L10N\IFactory;
|
||||
use OCP\Mail\IMailer;
|
||||
use OC\Settings\BackgroundJobs\VerifyUserData;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* @package OC\Settings\Controller
|
||||
|
@ -255,10 +258,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([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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#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'],
|
||||
|
|
|
@ -54,6 +54,14 @@
|
|||
<input type="checkbox" id="showStoragePath" class="checkbox" v-model="showStoragePath">
|
||||
<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>
|
||||
|
@ -63,6 +71,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import axios from '@nextcloud/axios'
|
||||
import Vue from 'vue';
|
||||
import VueLocalStorage from 'vue-localstorage'
|
||||
import {
|
||||
|
@ -122,6 +131,7 @@ export default {
|
|||
externalActions: [],
|
||||
showAddGroupEntry: false,
|
||||
loadingAddGroup: false,
|
||||
loadingSendMail: false,
|
||||
showConfig: {
|
||||
showStoragePath: 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
|
||||
menu() {
|
||||
// Data provided php side
|
||||
|
|
Loading…
Reference in a new issue