diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-10-20 15:27:05 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-10-20 15:27:05 +0200 |
commit | dbf5c266c772fc13c0380745dc5c340e33fecdf7 (patch) | |
tree | 39e2ca3c6588a37ee4163c7a83e6b9b03f89deb3 /settings | |
parent | 7010f42986bf5ecb17c9b855cf31b43699f8d612 (diff) | |
parent | f7b62abcce05f2170a3d376ea9f38ea1d0edabfa (diff) | |
download | nextcloud-server-dbf5c266c772fc13c0380745dc5c340e33fecdf7.tar.gz nextcloud-server-dbf5c266c772fc13c0380745dc5c340e33fecdf7.zip |
Merge pull request #19769 from owncloud/stable8.2-users-deletebeforecreate
[stable8.2] Delete last undoable user before user creation
Diffstat (limited to 'settings')
-rw-r--r-- | settings/js/users/deleteHandler.js | 5 | ||||
-rw-r--r-- | settings/js/users/users.js | 69 |
2 files changed, 43 insertions, 31 deletions
diff --git a/settings/js/users/deleteHandler.js b/settings/js/users/deleteHandler.js index de87f901372..b684aff1889 100644 --- a/settings/js/users/deleteHandler.js +++ b/settings/js/users/deleteHandler.js @@ -172,8 +172,9 @@ DeleteHandler.prototype.cancel = function() { * it, defaults to false */ DeleteHandler.prototype.deleteEntry = function(keepNotification) { + var deferred = $.Deferred(); if(this.canceled || this.oidToDelete === false) { - return false; + return deferred.resolve().promise(); } var dh = this; @@ -188,7 +189,7 @@ DeleteHandler.prototype.deleteEntry = function(keepNotification) { var payload = {}; payload[dh.ajaxParamID] = dh.oidToDelete; - $.ajax({ + return $.ajax({ type: 'DELETE', url: OC.generateUrl(dh.ajaxEndpoint+'/'+this.oidToDelete), // FIXME: do not use synchronous ajax calls as they block the browser ! diff --git a/settings/js/users/users.js b/settings/js/users/users.js index 519fe9655db..a99b46448be 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -9,6 +9,7 @@ var $userList; var $userListBody; +var UserDeleteHandler; var UserList = { availableGroups: [], offset: 0, @@ -785,37 +786,47 @@ $(document).ready(function () { t('settings', 'Error creating user')); return false; } - var groups = $('#newusergroups').val() || []; - $.post( - OC.generateUrl('/settings/users/users'), - { - username: username, - password: password, - groups: groups, - email: email - }, - function (result) { - if (result.groups) { - for (var i in result.groups) { - var gid = result.groups[i]; - if(UserList.availableGroups.indexOf(gid) === -1) { - UserList.availableGroups.push(gid); + + var promise; + if (UserDeleteHandler) { + promise = UserDeleteHandler.deleteEntry(); + } else { + promise = $.Deferred().resolve().promise(); + } + + promise.then(function() { + var groups = $('#newusergroups').val() || []; + $.post( + OC.generateUrl('/settings/users/users'), + { + username: username, + password: password, + groups: groups, + email: email + }, + function (result) { + if (result.groups) { + for (var i in result.groups) { + var gid = result.groups[i]; + if(UserList.availableGroups.indexOf(gid) === -1) { + UserList.availableGroups.push(gid); + } + $li = GroupList.getGroupLI(gid); + userCount = GroupList.getUserCount($li); + GroupList.setUserCount($li, userCount + 1); } - $li = GroupList.getGroupLI(gid); - userCount = GroupList.getUserCount($li); - GroupList.setUserCount($li, userCount + 1); } - } - if(!UserList.has(username)) { - UserList.add(result, true); - } - $('#newusername').focus(); - GroupList.incEveryoneCount(); - }).fail(function(result, textStatus, errorThrown) { - OC.dialogs.alert(result.responseJSON.message, t('settings', 'Error creating user')); - }).success(function(){ - $('#newuser').get(0).reset(); - }); + if(!UserList.has(username)) { + UserList.add(result, true); + } + $('#newusername').focus(); + GroupList.incEveryoneCount(); + }).fail(function(result, textStatus, errorThrown) { + OC.dialogs.alert(result.responseJSON.message, t('settings', 'Error creating user')); + }).success(function(){ + $('#newuser').get(0).reset(); + }); + }); }); if ($('#CheckboxStorageLocation').is(':checked')) { |