Skip to content

Commit

Permalink
Revive the "send email to new users" toggle for the user form
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Feb 27, 2020
1 parent d7523c7 commit 1606636
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 41 deletions.
2 changes: 1 addition & 1 deletion apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public function addUser(string $userid,
}

// Send new user mail only if a mail is set
if ($email !== '') {
if ($email !== '' && $this->config->getAppValue('core', 'newUser.sendEmail', 'no') === 'yes') {
$newUser->setEMailAddress($email);
try {
$emailTemplate = $this->newUserMailHelper->generateTemplate($newUser, $generatePasswordResetToken);
Expand Down
1 change: 1 addition & 0 deletions apps/settings/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
['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'],
Expand Down
18 changes: 9 additions & 9 deletions apps/settings/js/vue-0.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-0.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions apps/settings/js/vue-5.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-5.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/settings/js/vue-7.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-7.js.map

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions apps/settings/js/vue-settings-admin-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-admin-security.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/settings/js/vue-settings-apps-users-management.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions apps/settings/js/vue-settings-personal-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-personal-security.js.map

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions apps/settings/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
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;
Expand All @@ -52,6 +54,7 @@
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
use function in_array;

class UsersController extends Controller {
/** @var IUserManager */
Expand Down Expand Up @@ -238,10 +241,28 @@ public function usersList() {
$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
*
Expand Down
22 changes: 22 additions & 0 deletions apps/settings/src/views/Users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@
class="checkbox">
<label for="showStoragePath">{{ t('settings', 'Show storage path') }}</label>
</div>
<div>
<input id="sendWelcomeMail"
v-model="sendWelcomeMail"
type="checkbox"
class="checkbox">
<label for="sendWelcomeMail">{{ t('settings', 'Send email to new user') }}</label>
</div>
</AppNavigationSettings>
</AppNavigation>
<AppContent>
Expand All @@ -156,7 +163,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'
Expand Down Expand Up @@ -276,6 +285,19 @@ export default {

},

sendWelcomeMail: {
get() {
return this.settings.newUserSendEmail
},
set(value) {
this.$store.commit('setServerData', {
...this.settings,
newUserSendEmail: value
})
axios.post(generateUrl(`/settings/users/preferences/newUser.sendEmail`), { value: value ? 'yes' : 'no' })
},
},

groupList() {
const groups = Array.isArray(this.groups) ? this.groups : []

Expand Down

0 comments on commit 1606636

Please sign in to comment.