diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-02-15 12:17:55 -0600 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-02-15 17:45:38 -0600 |
commit | 2e88bec14bb9cee82c1f3e5479c081eeadd89be5 (patch) | |
tree | db530d28c2d457379c9e3f5e22d7aa19cff1ac2b /settings | |
parent | c3fe8f6cf27f45d3fbcdc625ba547e3736edd07a (diff) | |
download | nextcloud-server-2e88bec14bb9cee82c1f3e5479c081eeadd89be5.tar.gz nextcloud-server-2e88bec14bb9cee82c1f3e5479c081eeadd89be5.zip |
Fix setup issue and refine error messages
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'settings')
-rw-r--r-- | settings/Controller/UsersController.php | 19 | ||||
-rw-r--r-- | settings/js/users/users.js | 24 | ||||
-rw-r--r-- | settings/templates/users/main.php | 8 | ||||
-rw-r--r-- | settings/users.php | 1 |
4 files changed, 20 insertions, 32 deletions
diff --git a/settings/Controller/UsersController.php b/settings/Controller/UsersController.php index b81b0f3ee91..fb5e6af04a8 100644 --- a/settings/Controller/UsersController.php +++ b/settings/Controller/UsersController.php @@ -379,6 +379,21 @@ class UsersController extends Controller { ); } + $generatedPassword = false; + if ($password === '') { + if ($email === '') { + return new DataResponse( + array( + 'message' => (string)$this->l10n->t('To send a password link to the user an email address is required.') + ), + Http::STATUS_UNPROCESSABLE_ENTITY + ); + } + + $password = $this->secureRandom->generate(32); + $generatedPassword = true; + } + try { $user = $this->userManager->createUser($username, $password); } catch (\Exception $exception) { @@ -411,7 +426,7 @@ class UsersController extends Controller { if($email !== '') { $user->setEMailAddress($email); - if ($this->config->getAppValue('core', 'umgmt_send_passwordlink', 'false') === 'true') { + if ($generatedPassword) { $token = $this->secureRandom->generate( 21, ISecureRandom::CHAR_DIGITS . @@ -431,7 +446,7 @@ class UsersController extends Controller { // data for the mail template $mailData = array( 'username' => $username, - 'url' =>$link + 'url' => $link ); $mail = new TemplateResponse('settings', 'email.new_user', $mailData, 'blank'); diff --git a/settings/js/users/users.js b/settings/js/users/users.js index 55939c289c0..a6dcafcdac3 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -918,7 +918,7 @@ $(document).ready(function () { })); return false; } - if ($.trim(password) === '' && !$('#CheckboxMailPasswordOnUserCreate').is(':checked')) { + if ($.trim(password) === '' && !$('#CheckboxMailOnUserCreate').is(':checked')) { OC.Notification.showTemporary(t('settings', 'Error creating user: {message}', { message: t('settings', 'A valid password must be provided') })); @@ -1044,37 +1044,15 @@ $(document).ready(function () { if ($('#CheckboxMailOnUserCreate').is(':checked')) { $("#newemail").show(); - $("#MailPasswordOnUserCreateSetting").show(); } - - if ($('#CheckboxMailPasswordOnUserCreate').is(':checked')) { - $("#newuserpassword").hide(); - } else { - $("#newuserpassword").show(); - } - // Option to display/hide the "E-Mail" input field $('#CheckboxMailOnUserCreate').click(function() { if ($('#CheckboxMailOnUserCreate').is(':checked')) { $("#newemail").show(); - $("#MailPasswordOnUserCreateSetting").show(); OCP.AppConfig.setValue('core', 'umgmt_send_email', 'true'); } else { $("#newemail").hide(); - $("#MailPasswordOnUserCreateSetting").hide(); OCP.AppConfig.setValue('core', 'umgmt_send_email', 'false'); - OCP.AppConfig.setValue('core', 'umgmt_send_passwordlink', 'false'); - $('#CheckboxMailPasswordOnUserCreate').removeAttr('checked'); - } - }); - - $('#CheckboxMailPasswordOnUserCreate').click(function() { - if ($('#CheckboxMailPasswordOnUserCreate').is(':checked')) { - OCP.AppConfig.setValue('core', 'umgmt_send_passwordlink', 'true'); - $("#newuserpassword").hide(); - } else { - OCP.AppConfig.setValue('core', 'umgmt_send_passwordlink', 'false'); - $("#newuserpassword").show(); } }); diff --git a/settings/templates/users/main.php b/settings/templates/users/main.php index 59575a84e7e..44121a38d91 100644 --- a/settings/templates/users/main.php +++ b/settings/templates/users/main.php @@ -72,12 +72,8 @@ translation('settings'); <?php p($l->t('Send email to new user')) ?> </label> </p> - <p style="padding-left: 20px" id="MailPasswordOnUserCreateSetting"> - <input type="checkbox" name="MailPasswordOnUserCreate" value="MailPasswordOnUserCreate" id="CheckboxMailPasswordOnUserCreate" - class="checkbox" <?php if ($_['send_passwordlink'] === 'true') print_unescaped('checked="checked"'); ?> /> - <label for="CheckboxMailPasswordOnUserCreate"> - <?php p($l->t('Send password link')) ?> - </label> + <p class="info-text"> + When the password of the new user is left empty an activation email with a link to set the password is send to the user. </p> <p> <input type="checkbox" name="EmailAddress" value="EmailAddress" id="CheckboxEmailAddress" diff --git a/settings/users.php b/settings/users.php index 2532acdbb18..1b0f4f7b8e8 100644 --- a/settings/users.php +++ b/settings/users.php @@ -124,6 +124,5 @@ $tmpl->assign('show_last_login', $config->getAppValue('core', 'umgmt_show_last_l $tmpl->assign('show_email', $config->getAppValue('core', 'umgmt_show_email', 'false')); $tmpl->assign('show_backend', $config->getAppValue('core', 'umgmt_show_backend', 'false')); $tmpl->assign('send_email', $config->getAppValue('core', 'umgmt_send_email', 'false')); -$tmpl->assign('send_passwordlink', $config->getAppValue('core', 'umgmt_send_passwordlink', 'false')); $tmpl->printPage(); |