diff options
author | Joas Schilling <coding@schilljs.com> | 2016-11-11 09:43:43 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-11-18 12:10:51 +0100 |
commit | 02ea134152a3362702adf3477833268bf45656f8 (patch) | |
tree | 0a55b79c1ac2623b17d1200ed8908841533e8372 /settings/js | |
parent | a53c313878d04b71b383af7e5d013f30f07ae1e2 (diff) | |
download | nextcloud-server-02ea134152a3362702adf3477833268bf45656f8.tar.gz nextcloud-server-02ea134152a3362702adf3477833268bf45656f8.zip |
Fix error displaying on email and add confirmation
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'settings/js')
-rw-r--r-- | settings/js/users/users.js | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/settings/js/users/users.js b/settings/js/users/users.js index 6847f06a8b2..3f8016bb86e 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -784,6 +784,41 @@ $(document).ready(function () { }); }); + var _submitEmailChange = function($tr, $td, $input, uid, mailAddress) { + if (OC.PasswordConfirmation.requiresPasswordConfirmation()) { + OC.PasswordConfirmation.requirePasswordConfirmation(function() { + _submitEmailChange($tr, $td, $input, uid, mailAddress); + }); + return; + } + + $.ajax({ + type: 'PUT', + url: OC.generateUrl('/settings/users/{id}/mailAddress', {id: uid}), + data: { + mailAddress: mailAddress + } + }).success(function () { + // set data attribute to new value + // will in blur() be used to show the text instead of the input field + $tr.data('mailAddress', mailAddress); + $td.find('.loading-small').css('display', ''); + $input.removeAttr('disabled') + .triggerHandler('blur'); // needed instead of $input.blur() for Firefox + }).fail(function (result) { + if (!_.isUndefined(result.responseJSON.data)) { + OC.Notification.showTemporary(result.responseJSON.data.message); + } else if (!_.isUndefined(result.responseJSON.message)) { + OC.Notification.showTemporary(result.responseJSON.message); + } else { + OC.Notification.showTemporary(t('settings', 'Could not change the users email')); + } + $td.find('.loading-small').css('display', ''); + $input.removeAttr('disabled') + .css('padding-right', '6px'); + }); + }; + $userListBody.on('click', '.mailAddress', function (event) { event.stopPropagation(); var $td = $(this).closest('td'); @@ -799,29 +834,10 @@ $(document).ready(function () { if (event.keyCode === 13) { // enter key - var mailAddress = $input.val(); $td.find('.loading-small').css('display', 'inline-block'); $input.css('padding-right', '26px'); $input.attr('disabled', 'disabled'); - $.ajax({ - type: 'PUT', - url: OC.generateUrl('/settings/users/{id}/mailAddress', {id: uid}), - data: { - mailAddress: $(this).val() - } - }).success(function () { - // set data attribute to new value - // will in blur() be used to show the text instead of the input field - $tr.data('mailAddress', mailAddress); - $td.find('.loading-small').css('display', ''); - $input.removeAttr('disabled') - .triggerHandler('blur'); // needed instead of $input.blur() for Firefox - }).fail(function (result) { - OC.Notification.showTemporary(result.responseJSON.data.message); - $td.find('.loading-small').css('display', ''); - $input.removeAttr('disabled') - .css('padding-right', '6px'); - }); + _submitEmailChange($tr, $td, $input, uid, $(this).val()); } }) .blur(function () { @@ -930,7 +946,7 @@ $(document).ready(function () { $('#newuser').get(0).reset(); }); }); - } + }; $('#newuser').submit(_submitNewUserForm); if ($('#CheckboxStorageLocation').is(':checked')) { |