2012-02-22 16:20:46 -05:00
|
|
|
/**
|
2013-09-27 11:02:57 -04:00
|
|
|
* Copyright (c) 2013
|
|
|
|
|
* Sam Tuke <samtuke@owncloud.com>
|
|
|
|
|
* Robin Appelman <icewind1991@gmail.com>
|
|
|
|
|
* Bjoern Schiessle <schiessle@owncloud.com>
|
2012-02-22 16:20:46 -05:00
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
|
* See the COPYING-README file.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
2013-03-29 16:11:29 -04:00
|
|
|
// Trigger ajax on recoveryAdmin status change
|
2013-05-15 05:42:22 -04:00
|
|
|
var enabledStatus = $('#adminEnableRecovery').val();
|
|
|
|
|
|
2013-09-18 10:03:53 -04:00
|
|
|
$('input:password[name="encryptionRecoveryPassword"]').keyup(function(event) {
|
|
|
|
|
var recoveryPassword = $( '#encryptionRecoveryPassword' ).val();
|
|
|
|
|
var recoveryPasswordRepeated = $( '#repeatEncryptionRecoveryPassword' ).val();
|
2013-05-15 05:42:22 -04:00
|
|
|
var checkedButton = $('input:radio[name="adminEnableRecovery"]:checked').val();
|
|
|
|
|
var uncheckedValue = (1+parseInt(checkedButton)) % 2;
|
2013-09-19 04:13:21 -04:00
|
|
|
if (recoveryPassword !== '' && recoveryPassword === recoveryPasswordRepeated) {
|
2013-05-15 05:42:22 -04:00
|
|
|
$('input:radio[name="adminEnableRecovery"][value="'+uncheckedValue.toString()+'"]').removeAttr("disabled");
|
|
|
|
|
} else {
|
|
|
|
|
$('input:radio[name="adminEnableRecovery"][value="'+uncheckedValue.toString()+'"]').attr("disabled", "true");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2013-09-18 10:03:53 -04:00
|
|
|
$( 'input:radio[name="adminEnableRecovery"]' ).change(
|
2013-03-29 16:11:29 -04:00
|
|
|
function() {
|
2013-05-01 13:18:31 -04:00
|
|
|
var recoveryStatus = $( this ).val();
|
2013-05-15 08:02:13 -04:00
|
|
|
var oldStatus = (1+parseInt(recoveryStatus)) % 2;
|
2013-09-18 10:03:53 -04:00
|
|
|
var recoveryPassword = $( '#encryptionRecoveryPassword' ).val();
|
2013-05-15 05:42:22 -04:00
|
|
|
$.post(
|
|
|
|
|
OC.filePath( 'files_encryption', 'ajax', 'adminrecovery.php' )
|
|
|
|
|
, { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword }
|
2013-05-22 12:01:18 -04:00
|
|
|
, function( result ) {
|
|
|
|
|
if (result.status === "error") {
|
|
|
|
|
OC.Notification.show(t('admin', result.data.message));
|
2013-05-15 08:02:13 -04:00
|
|
|
$('input:radio[name="adminEnableRecovery"][value="'+oldStatus.toString()+'"]').attr("checked", "true");
|
2013-05-15 10:12:20 -04:00
|
|
|
} else {
|
2013-05-22 12:01:18 -04:00
|
|
|
OC.Notification.hide();
|
|
|
|
|
if (recoveryStatus === "0") {
|
2013-10-03 06:22:25 -04:00
|
|
|
$('p[name="changeRecoveryPasswordBlock"]').addClass("hidden");
|
2013-05-15 10:12:20 -04:00
|
|
|
} else {
|
2013-09-18 10:03:53 -04:00
|
|
|
$('input:password[name="changeRecoveryPassword"]').val("");
|
2013-10-03 06:22:25 -04:00
|
|
|
$('p[name="changeRecoveryPasswordBlock"]').removeClass("hidden");
|
2013-05-15 10:12:20 -04:00
|
|
|
}
|
2013-05-15 08:02:13 -04:00
|
|
|
}
|
2013-05-15 05:42:22 -04:00
|
|
|
}
|
|
|
|
|
);
|
2013-03-29 16:11:29 -04:00
|
|
|
}
|
|
|
|
|
);
|
2013-05-15 10:12:20 -04:00
|
|
|
|
2013-05-16 08:53:04 -04:00
|
|
|
// change recovery password
|
2013-05-15 10:12:20 -04:00
|
|
|
|
|
|
|
|
$('input:password[name="changeRecoveryPassword"]').keyup(function(event) {
|
2013-09-18 10:03:53 -04:00
|
|
|
var oldRecoveryPassword = $('#oldEncryptionRecoveryPassword').val();
|
|
|
|
|
var newRecoveryPassword = $('#newEncryptionRecoveryPassword').val();
|
|
|
|
|
var newRecoveryPasswordRepeated = $('#repeatedNewEncryptionRecoveryPassword').val();
|
2013-09-18 10:08:29 -04:00
|
|
|
|
2013-09-18 10:03:53 -04:00
|
|
|
if (newRecoveryPassword !== '' && oldRecoveryPassword !== '' && newRecoveryPassword === newRecoveryPasswordRepeated) {
|
2013-05-15 10:12:20 -04:00
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').removeAttr("disabled");
|
|
|
|
|
} else {
|
|
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').attr("disabled", "true");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('button:button[name="submitChangeRecoveryKey"]').click(function() {
|
2013-09-18 10:03:53 -04:00
|
|
|
var oldRecoveryPassword = $('#oldEncryptionRecoveryPassword').val();
|
|
|
|
|
var newRecoveryPassword = $('#newEncryptionRecoveryPassword').val();
|
2013-05-15 10: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 10:03:53 -04:00
|
|
|
|
2013-08-18 05:02:08 -04:00
|
|
|
});
|