diff options
author | Brice Maron <brice@bmaron.net> | 2012-05-07 16:08:15 +0000 |
---|---|---|
committer | Brice Maron <brice@bmaron.net> | 2012-05-07 16:08:35 +0000 |
commit | da4688d804717599213e2a7a66c24e5b98edca17 (patch) | |
tree | 1a6471f8ca787e619c23af9023716cd6fc873120 /settings/js | |
parent | e9c7ecf22dbc2e04e2d6122bfb515cc95de9e75f (diff) | |
download | nextcloud-server-da4688d804717599213e2a7a66c24e5b98edca17.tar.gz nextcloud-server-da4688d804717599213e2a7a66c24e5b98edca17.zip |
Reorder code to avoid race condition in user creation
Diffstat (limited to 'settings/js')
-rw-r--r-- | settings/js/users.js | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/settings/js/users.js b/settings/js/users.js index e6eee4ce4fa..33872ceaf7b 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -167,22 +167,7 @@ $(document).ready(function(){ } var password=$('#newuserpassword').val(); var groups=$('#newusergroups').prev().children('div').data('settings').checked; - var tr - $.post( - OC.filePath('settings','ajax','createuser.php'), - { - username:username, - password:password, - groups:groups, - }, - function(result){ - if(result.status!='success'){ - tr.remove(); - OC.dialogs.alert(result.data.message, 'Error creating user'); - } - } - ); - tr=$('#content table tbody tr').first().clone(); + var tr=$('#content table tbody tr').first().clone(); tr.attr('data-uid',username); tr.find('td.name').text(username); var select=$('<select multiple="multiple" data-placehoder="Groups" title="Groups">'); @@ -203,10 +188,24 @@ $(document).ready(function(){ tr.find('td.remove').append($('<img alt="Delete" title="'+t('settings','Delete')+'" class="svg action" src="'+OC.imagePath('core','actions/delete')+'"/>')); } applyMultiplySelect(select); - $('#content table tbody').last().after(tr); + $('#content table tbody').last().append(tr); tr.find('select.quota option').attr('selected',null); tr.find('select.quota option').first().attr('selected','selected'); tr.find('select.quota').data('previous','default'); + $.post( + OC.filePath('settings','ajax','createuser.php'), + { + username:username, + password:password, + groups:groups, + }, + function(result){ + if(result.status!='success'){ + tr.remove(); + OC.dialogs.alert(result.data.message, 'Error creating user'); + } + } + ); }); }); |