summaryrefslogtreecommitdiffstats
path: root/settings/js
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-10-14 12:51:51 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-10-14 12:51:51 +0200
commit4b8632325ae235bc41af809d47631d0088030110 (patch)
tree32be7567d55af51c246097d632008980fc94a73a /settings/js
parent3aeda33a996d81d6ccdbbedaa5ff69b5b0f5e2de (diff)
parenta73f31d3a562d970a5d5886e0d881b0522b42ae1 (diff)
downloadnextcloud-server-4b8632325ae235bc41af809d47631d0088030110.tar.gz
nextcloud-server-4b8632325ae235bc41af809d47631d0088030110.zip
Merge pull request #19627 from owncloud/users-deletebeforecreate
Delete last undoable user before user creation
Diffstat (limited to 'settings/js')
-rw-r--r--settings/js/users/deleteHandler.js5
-rw-r--r--settings/js/users/users.js69
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')) {