diff options
author | Joas Schilling <coding@schilljs.com> | 2016-11-03 10:13:00 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-11-18 12:10:51 +0100 |
commit | 309b21f5a09385f4813a0115076e4fccb0b7034d (patch) | |
tree | 66d3b99e4b1e26c05a51f5724a6f8f7323134ba5 /settings/js | |
parent | a7feb91282744b2f52b1a9a9d4fba99fa1ad4a9a (diff) | |
download | nextcloud-server-309b21f5a09385f4813a0115076e4fccb0b7034d.tar.gz nextcloud-server-309b21f5a09385f4813a0115076e4fccb0b7034d.zip |
Require confirmation to change the displayname
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'settings/js')
-rw-r--r-- | settings/js/users/users.js | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/settings/js/users/users.js b/settings/js/users/users.js index 0e500c328fd..c2f1eb3c00f 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -717,6 +717,36 @@ $(document).ready(function () { OC.Notification.hide(); }); + var _submitDisplayNameChange = function($tr, uid, displayName) { + var $div = $tr.find('div.avatardiv'); + if ($div.length) { + $div.imageplaceholder(uid, displayName); + } + + if (OC.PasswordConfirmation.requiresPasswordConfirmation()) { + OC.PasswordConfirmation.requirePasswordConfirmation(function() { + _submitDisplayNameChange($tr, uid, displayName); + }); + return; + } + + $.ajax({ + type: 'POST', + url: OC.generateUrl('/settings/users/{id}/displayName', {id: uid}), + data: { + username: uid, + displayName: displayName + } + }).success(function () { + if (result && result.status==='success' && $div.length){ + $div.avatar(result.data.username, 32); + } + $tr.data('displayname', displayName); + }).fail(function (result) { + OC.Notification.showTemporary(result.responseJSON.message); + }); + }; + $userListBody.on('click', '.displayName', function (event) { event.stopPropagation(); var $td = $(this).closest('td'); @@ -731,21 +761,7 @@ $(document).ready(function () { .keypress(function (event) { if (event.keyCode === 13) { if ($(this).val().length > 0) { - var $div = $tr.find('div.avatardiv'); - if ($div.length) { - $div.imageplaceholder(uid, displayName); - } - $.post( - OC.generateUrl('/settings/users/{id}/displayName', {id: uid}), - {username: uid, displayName: $(this).val()}, - function (result) { - if (result && result.status==='success' && $div.length){ - $div.avatar(result.data.username, 32); - } - } - ); - var displayName = $input.val(); - $tr.data('displayname', displayName); + _submitDisplayNameChange($tr, uid, $(this).val()); $input.blur(); } else { $input.blur(); |