nextcloud/apps/encryption/js/settings-personal.js

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

65 lines
2.3 KiB
JavaScript
Raw 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 || {}, {
updatePrivateKeyPassword: function() {
const oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val()
const newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val()
OC.msg.startSaving('#ocDefaultEncryptionModule .msg')
2015-04-21 06:01:56 -04: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)
}).fail(function(jqXHR) {
OC.msg.finishedError('#ocDefaultEncryptionModule .msg', JSON.parse(jqXHR.responseText).message)
})
},
})
2015-03-26 20:35:36 -04:00
window.addEventListener('DOMContentLoaded', function() {
2015-03-26 20:35:36 -04:00
// Trigger ajax on recoveryAdmin status change
$('input:radio[name="userEnableRecovery"]').change(function() {
const recoveryStatus = $(this).val()
OC.msg.startAction('#userEnableRecovery .msg', 'Updating recovery keys. This can take some time...')
$.post(
OC.generateUrl('/apps/encryption/ajax/userSetRecovery'),
{
userEnableRecovery: recoveryStatus,
},
).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
})
2015-03-26 20:35:36 -04:00
// update private key password
$('input:password[name="changePrivateKeyPassword"]').keyup(function(event) {
const oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val()
const newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val()
2015-04-22 10:41:47 -04:00
if (newPrivateKeyPassword !== '' && oldPrivateKeyPassword !== '') {
$('button:button[name="submitChangePrivateKeyPassword"]').removeAttr('disabled')
2015-04-22 10:41:47 -04:00
if (event.which === 13) {
OC.Encryption.updatePrivateKeyPassword()
2015-03-26 20:35:36 -04:00
}
} else {
$('button:button[name="submitChangePrivateKeyPassword"]').attr('disabled', 'true')
2015-03-26 20:35:36 -04:00
}
})
2015-03-26 20:35:36 -04:00
$('button:button[name="submitChangePrivateKeyPassword"]').click(function() {
OC.Encryption.updatePrivateKeyPassword()
})
})