2012-02-23 01:20:46 +04:00
|
|
|
/**
|
2013-09-27 19:02:57 +04:00
|
|
|
* Copyright (c) 2013
|
|
|
|
* Sam Tuke <samtuke@owncloud.com>
|
|
|
|
* Robin Appelman <icewind1991@gmail.com>
|
|
|
|
* Bjoern Schiessle <schiessle@owncloud.com>
|
2012-02-23 01:20:46 +04:00
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
2013-05-15 13:42:22 +04:00
|
|
|
|
2013-09-18 18:03:53 +04:00
|
|
|
$( 'input:radio[name="adminEnableRecovery"]' ).change(
|
2013-03-30 00:11:29 +04:00
|
|
|
function() {
|
2013-05-01 21:18:31 +04:00
|
|
|
var recoveryStatus = $( this ).val();
|
2013-05-15 16:02:13 +04:00
|
|
|
var oldStatus = (1+parseInt(recoveryStatus)) % 2;
|
2013-09-18 18:03:53 +04:00
|
|
|
var recoveryPassword = $( '#encryptionRecoveryPassword' ).val();
|
2014-10-07 14:06:46 +04:00
|
|
|
var confirmPassword = $( '#repeatEncryptionRecoveryPassword' ).val();
|
|
|
|
OC.msg.startSaving('#encryptionSetRecoveryKey .msg');
|
2013-05-15 13:42:22 +04:00
|
|
|
$.post(
|
|
|
|
OC.filePath( 'files_encryption', 'ajax', 'adminrecovery.php' )
|
2014-10-07 14:06:46 +04:00
|
|
|
, { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword, confirmPassword: confirmPassword }
|
2013-05-22 20:01:18 +04:00
|
|
|
, function( result ) {
|
2014-10-07 14:06:46 +04:00
|
|
|
OC.msg.finishedSaving('#encryptionSetRecoveryKey .msg', result);
|
2013-05-22 20:01:18 +04:00
|
|
|
if (result.status === "error") {
|
2013-05-15 16:02:13 +04:00
|
|
|
$('input:radio[name="adminEnableRecovery"][value="'+oldStatus.toString()+'"]').attr("checked", "true");
|
2013-05-15 18:12:20 +04:00
|
|
|
} else {
|
2013-05-22 20:01:18 +04:00
|
|
|
if (recoveryStatus === "0") {
|
2013-10-03 14:22:25 +04:00
|
|
|
$('p[name="changeRecoveryPasswordBlock"]').addClass("hidden");
|
2013-05-15 18:12:20 +04:00
|
|
|
} else {
|
2013-09-18 18:03:53 +04:00
|
|
|
$('input:password[name="changeRecoveryPassword"]').val("");
|
2013-10-03 14:22:25 +04:00
|
|
|
$('p[name="changeRecoveryPasswordBlock"]').removeClass("hidden");
|
2013-05-15 18:12:20 +04:00
|
|
|
}
|
2013-05-15 16:02:13 +04:00
|
|
|
}
|
2013-05-15 13:42:22 +04:00
|
|
|
}
|
|
|
|
);
|
2013-03-30 00:11:29 +04:00
|
|
|
}
|
|
|
|
);
|
2013-05-15 18:12:20 +04:00
|
|
|
|
2013-05-16 16:53:04 +04:00
|
|
|
// change recovery password
|
2013-05-15 18:12:20 +04:00
|
|
|
|
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').click(function() {
|
2013-09-18 18:03:53 +04:00
|
|
|
var oldRecoveryPassword = $('#oldEncryptionRecoveryPassword').val();
|
|
|
|
var newRecoveryPassword = $('#newEncryptionRecoveryPassword').val();
|
2013-05-15 18:12:20 +04:00
|
|
|
OC.msg.startSaving('#encryption .msg');
|
|
|
|
$.post(
|
|
|
|
OC.filePath( 'files_encryption', 'ajax', 'changeRecoveryPassword.php' )
|
|
|
|
, { oldPassword: oldRecoveryPassword, newPassword: newRecoveryPassword }
|
|
|
|
, function( data ) {
|
|
|
|
if (data.status == "error") {
|
|
|
|
OC.msg.finishedSaving('#encryption .msg', data);
|
|
|
|
} else {
|
|
|
|
OC.msg.finishedSaving('#encryption .msg', data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2013-09-18 18:03:53 +04:00
|
|
|
|
2013-08-18 13:02:08 +04:00
|
|
|
});
|