0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-05-17 19:52:39 +00:00
nextcloud_server/apps/encryption/js/settings-personal.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
2.4 KiB
JavaScript
Raw Permalink Normal View History

2015-03-26 20:35:36 -04:00
/**
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2013-2015 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-or-later
2015-03-26 20:35:36 -04:00
*/
OC.Encryption = _.extend(OC.Encryption || {}, {
2015-04-22 10:41:47 -04:00
updatePrivateKeyPassword: function () {
2015-04-21 12:01:56 +02:00
var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
OC.msg.startSaving('#ocDefaultEncryptionModule .msg');
2015-04-21 12:01:56 +02:00
$.post(
OC.generateUrl('/apps/encryption/ajax/updatePrivateKeyPassword'),
2015-04-22 10:41:47 -04:00
{
oldPassword: oldPrivateKeyPassword,
newPassword: newPrivateKeyPassword
}
).done(function (data) {
OC.msg.finishedSuccess('#ocDefaultEncryptionModule .msg', data.message);
2015-04-22 10:41:47 -04:00
})
.fail(function (jqXHR) {
OC.msg.finishedError('#ocDefaultEncryptionModule .msg', JSON.parse(jqXHR.responseText).message);
2015-04-22 10:41:47 -04:00
});
2015-04-21 12:01:56 +02:00
}
});
2015-04-21 12:01:56 +02:00
window.addEventListener('DOMContentLoaded', function () {
2015-03-26 20:35:36 -04:00
// Trigger ajax on recoveryAdmin status change
2015-04-22 10:41:47 -04:00
$('input:radio[name="userEnableRecovery"]').change(
function () {
var recoveryStatus = $(this).val();
2015-03-26 20:35:36 -04:00
OC.msg.startAction('#userEnableRecovery .msg', 'Updating recovery keys. This can take some time...');
$.post(
2015-04-22 10:41:47 -04:00
OC.generateUrl('/apps/encryption/ajax/userSetRecovery'),
{
userEnableRecovery: recoveryStatus
2015-03-26 20:35:36 -04:00
}
2015-04-22 10:41:47 -04:00
).done(function (data) {
OC.msg.finishedSuccess('#userEnableRecovery .msg', data.data.message);
})
.fail(function (jqXHR) {
OC.msg.finishedError('#userEnableRecovery .msg', JSON.parse(jqXHR.responseText).data.message);
});
2015-03-26 20:35:36 -04:00
// Ensure page is not reloaded on form submit
return false;
}
);
// update private key password
2015-04-22 10:41:47 -04:00
$('input:password[name="changePrivateKeyPassword"]').keyup(function (event) {
2015-03-26 20:35:36 -04:00
var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
2015-04-22 10:41:47 -04:00
if (newPrivateKeyPassword !== '' && oldPrivateKeyPassword !== '') {
2015-03-26 20:35:36 -04:00
$('button:button[name="submitChangePrivateKeyPassword"]').removeAttr("disabled");
2015-04-22 10:41:47 -04:00
if (event.which === 13) {
2015-04-21 12:01:56 +02:00
OC.Encryption.updatePrivateKeyPassword();
2015-03-26 20:35:36 -04:00
}
} else {
$('button:button[name="submitChangePrivateKeyPassword"]').attr("disabled", "true");
}
});
2015-04-22 10:41:47 -04:00
$('button:button[name="submitChangePrivateKeyPassword"]').click(function () {
2015-04-21 12:01:56 +02:00
OC.Encryption.updatePrivateKeyPassword();
2015-03-26 20:35:36 -04:00
});
});