Require confirmation to change the displayname

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2016-11-03 10:13:00 +01:00 committed by Lukas Reschke
parent a7feb91282
commit 309b21f5a0
No known key found for this signature in database
GPG Key ID: B9F6980CF6E759B1
1 changed files with 31 additions and 15 deletions

View File

@ -717,6 +717,36 @@ $(document).ready(function () {
OC.Notification.hide(); 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) { $userListBody.on('click', '.displayName', function (event) {
event.stopPropagation(); event.stopPropagation();
var $td = $(this).closest('td'); var $td = $(this).closest('td');
@ -731,21 +761,7 @@ $(document).ready(function () {
.keypress(function (event) { .keypress(function (event) {
if (event.keyCode === 13) { if (event.keyCode === 13) {
if ($(this).val().length > 0) { if ($(this).val().length > 0) {
var $div = $tr.find('div.avatardiv'); _submitDisplayNameChange($tr, uid, $(this).val());
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);
$input.blur(); $input.blur();
} else { } else {
$input.blur(); $input.blur();