]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added warning notification when user home already exists
authorVincent Petry <pvince81@owncloud.com>
Tue, 22 Oct 2013 16:09:40 +0000 (18:09 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 22 Oct 2013 16:10:29 +0000 (18:10 +0200)
When creating a user and the home already exists in the data dir, a
warning notification will be displayed.

Fixes #5161

settings/ajax/createuser.php
settings/js/users.js

index ccc2a5d402e8756bb5be46796baa7519e92e5aa2..915fcaf2d428843a6ca2248618cc5554f4139a4e 100644 (file)
@@ -38,8 +38,15 @@ try {
                }
                OC_Group::addToGroup( $username, $i );
        }
+
+       // check whether the user's files home exists
+       $userDirectory = OC_User::getHome($username) . '/files/';
+       $homeExists = file_exists($userDirectory);
+
        OC_JSON::success(array("data" =>
                                array(
+                                       // returns whether the home already existed
+                                       "homeExists" => $homeExists,
                                        "username" => $username,
                                        "groups" => OC_Group::getUserGroups( $username ))));
 } catch (Exception $exception) {
index 5b7802c1e362a25d38ade8759ef28191631c6eca..4c2ad5417ca5531c8c24ce6dd12db35c861c2aed 100644 (file)
@@ -467,6 +467,18 @@ $(document).ready(function () {
                                                var addedGroups = result.data.groups;
                                                UserList.availableGroups = $.unique($.merge(UserList.availableGroups, addedGroups));
                                        }
+                                       if (result.data.homeExists){
+                                               OC.Notification.hide();
+                                               OC.Notification.show(t('settings', 'Warning: Home directory for user "{user}" already exists', {user: result.data.username}));
+                                               if (UserList.notificationTimeout){
+                                                       window.clearTimeout(UserList.notificationTimeout);
+                                               }
+                                               UserList.notificationTimeout = window.setTimeout(
+                                                       function(){
+                                                               OC.Notification.hide();
+                                                               UserList.notificationTimeout = null;
+                                                       }, 10000);
+                                       }
                                        if($('tr[data-uid="' + username + '"]').length === 0) {
                                                UserList.add(username, username, result.data.groups, null, 'default', true);
                                        }