2015-03-27 00:35:36 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2013
|
|
|
|
* Sam Tuke <samtuke@owncloud.com>
|
|
|
|
* Robin Appelman <icewind1991@gmail.com>
|
|
|
|
* Bjoern Schiessle <schiessle@owncloud.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2015-04-22 14:41:47 +00:00
|
|
|
$(document).ready(function () {
|
2015-03-27 00:35:36 +00:00
|
|
|
|
2015-04-22 14:41:47 +00:00
|
|
|
$('input:radio[name="adminEnableRecovery"]').change(
|
|
|
|
function () {
|
|
|
|
var recoveryStatus = $(this).val();
|
|
|
|
var oldStatus = (1 + parseInt(recoveryStatus)) % 2;
|
|
|
|
var recoveryPassword = $('#encryptionRecoveryPassword').val();
|
|
|
|
var confirmPassword = $('#repeatEncryptionRecoveryPassword').val();
|
2015-03-27 00:35:36 +00:00
|
|
|
OC.msg.startSaving('#encryptionSetRecoveryKey .msg');
|
|
|
|
$.post(
|
2015-04-17 16:04:07 +00:00
|
|
|
OC.generateUrl('/apps/encryption/ajax/adminRecovery'),
|
2015-04-22 14:41:47 +00:00
|
|
|
{
|
|
|
|
adminEnableRecovery: recoveryStatus,
|
2015-04-17 16:04:07 +00:00
|
|
|
recoveryPassword: recoveryPassword,
|
2015-04-22 14:41:47 +00:00
|
|
|
confirmPassword: confirmPassword
|
|
|
|
}
|
|
|
|
).done(function (data) {
|
|
|
|
OC.msg.finishedSuccess('#encryptionSetRecoveryKey .msg', data.data.message);
|
|
|
|
|
|
|
|
if (recoveryStatus === "0") {
|
|
|
|
$('p[name="changeRecoveryPasswordBlock"]').addClass("hidden");
|
2015-03-27 00:35:36 +00:00
|
|
|
} else {
|
2015-04-22 14:41:47 +00:00
|
|
|
$('input:password[name="changeRecoveryPassword"]').val("");
|
|
|
|
$('p[name="changeRecoveryPasswordBlock"]').removeClass("hidden");
|
2015-03-27 00:35:36 +00:00
|
|
|
}
|
2015-04-22 14:41:47 +00:00
|
|
|
})
|
|
|
|
.fail(function (jqXHR) {
|
|
|
|
$('input:radio[name="adminEnableRecovery"][value="' + oldStatus.toString() + '"]').attr("checked", "true");
|
|
|
|
OC.msg.finishedError('#encryptionSetRecoveryKey .msg', JSON.parse(jqXHR.responseText).data.message);
|
|
|
|
});
|
2015-03-27 00:35:36 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// change recovery password
|
|
|
|
|
2015-04-22 14:41:47 +00:00
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').click(function () {
|
2015-03-27 00:35:36 +00:00
|
|
|
var oldRecoveryPassword = $('#oldEncryptionRecoveryPassword').val();
|
|
|
|
var newRecoveryPassword = $('#newEncryptionRecoveryPassword').val();
|
|
|
|
var confirmNewPassword = $('#repeatedNewEncryptionRecoveryPassword').val();
|
|
|
|
OC.msg.startSaving('#encryptionChangeRecoveryKey .msg');
|
|
|
|
$.post(
|
2015-04-22 14:41:47 +00:00
|
|
|
OC.generateUrl('/apps/encryption/ajax/changeRecoveryPassword'),
|
|
|
|
{
|
|
|
|
oldPassword: oldRecoveryPassword,
|
|
|
|
newPassword: newRecoveryPassword,
|
|
|
|
confirmPassword: confirmNewPassword
|
|
|
|
}
|
|
|
|
).done(function (data) {
|
|
|
|
OC.msg.finishedSuccess('#encryptionChangeRecoveryKey .msg', data.data.message);
|
|
|
|
})
|
|
|
|
.fail(function (jqXHR) {
|
|
|
|
OC.msg.finishedError('#encryptionChangeRecoveryKey .msg', JSON.parse(jqXHR.responseText).data.message);
|
|
|
|
});
|
2015-03-27 00:35:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|