]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix setup issue and refine error messages
authorMorris Jobke <hey@morrisjobke.de>
Wed, 15 Feb 2017 18:17:55 +0000 (12:17 -0600)
committerMorris Jobke <hey@morrisjobke.de>
Wed, 15 Feb 2017 23:45:38 +0000 (17:45 -0600)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
core/css/apps.scss
lib/private/User/Manager.php
settings/Controller/UsersController.php
settings/js/users/users.js
settings/templates/users/main.php
settings/users.php

index f1ddc95e092f2a5a0619f8d87ee80c136525051c..91805fe16b29ac42bd908ea95f17750fe6e524a2 100644 (file)
@@ -420,6 +420,11 @@ em {
        input[type='text'] {
                width: 93%;
        }
+
+       .info-text {
+               padding: 5px 0 7px 22px;
+               color: #999;
+       }
 }
 
 #app-settings-header {
index b1f328b6f1b64299bcef1b33778d07643a6d0cc1..3d016700ee333968997cb80e97dbd6d5f379d153 100644 (file)
@@ -281,11 +281,9 @@ class Manager extends PublicEmitter implements IUserManager {
                if (strlen(trim($uid, "\t\n\r\0\x0B\xe2\x80\x8b")) !== strlen(trim($uid))) {
                        throw new \Exception($l->t('Username contains whitespace at the beginning or at the end'));
                }
-               // if password link is sent use random password; permit empty password
-               if (trim($password) == '' && $this->config->getAppValue('core', 'umgmt_send_passwordlink', 'false') === 'false') {
+               // No empty password
+               if (trim($password) == '') {
                        throw new \Exception($l->t('A valid password must be provided'));
-               } else {
-                       $password = \OC::$server->getSecureRandom()->generate(32);
                }
 
                // Check if user already exists
index b81b0f3ee914bbb7a205fdbca69c52812c04497c..fb5e6af04a82b987db4ec83fdb3290612d7d5adb 100644 (file)
@@ -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');
index 55939c289c0460c42792613610e3731d394efd8e..a6dcafcdac3c6b487e3dd21b535fb3109d1d3a29 100644 (file)
@@ -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();
                }
        });
 
index 59575a84e7e51c487f85f41ef8cc16e63a8ce3d2..44121a38d9192c5d78ea102745040883f5ef924a 100644 (file)
@@ -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"
index 2532acdbb18f9753abb96e6277f417ffba1738c6..1b0f4f7b8e83751ff722bb4ff9947148cf1f6205 100644 (file)
@@ -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();