Skip to content
Snippets Groups Projects
Commit 15a3ae6d authored by Björn Schießle's avatar Björn Schießle
Browse files

improved error messages

parent ee53bd1a
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ $recoveryKeyId = OC_Appconfig::getValue('files_encryption', 'recoveryKeyId'); ...@@ -22,6 +22,7 @@ $recoveryKeyId = OC_Appconfig::getValue('files_encryption', 'recoveryKeyId');
if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] == 1){ if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] == 1){
$return = \OCA\Encryption\Helper::adminEnableRecovery($recoveryKeyId, $_POST['recoveryPassword']); $return = \OCA\Encryption\Helper::adminEnableRecovery($recoveryKeyId, $_POST['recoveryPassword']);
$action = "enable";
// Disable recoveryAdmin // Disable recoveryAdmin
} elseif ( } elseif (
...@@ -29,7 +30,12 @@ if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] == 1){ ...@@ -29,7 +30,12 @@ if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] == 1){
&& 0 == $_POST['adminEnableRecovery'] && 0 == $_POST['adminEnableRecovery']
) { ) {
$return = \OCA\Encryption\Helper::adminDisableRecovery($_POST['recoveryPassword']); $return = \OCA\Encryption\Helper::adminDisableRecovery($_POST['recoveryPassword']);
$action = "disable";
} }
// Return success or failure // Return success or failure
( $return ) ? \OCP\JSON::success() : \OCP\JSON::error(); if ($return) {
\ No newline at end of file \OCP\JSON::success(array("data" => array( "message" => 'Recovery key successfully ' . $action.'d')));
} else {
\OCP\JSON::error(array("data" => array( "message" => 'Could not '.$action.' recovery key. Please check your recovery key password!')));
}
...@@ -44,19 +44,19 @@ $(document).ready(function(){ ...@@ -44,19 +44,19 @@ $(document).ready(function(){
$( 'input:radio[name="adminEnableRecovery"]' ).change( $( 'input:radio[name="adminEnableRecovery"]' ).change(
function() { function() {
var recoveryStatus = $( this ).val(); var recoveryStatus = $( this ).val();
var oldStatus = (1+parseInt(recoveryStatus)) % 2; var oldStatus = (1+parseInt(recoveryStatus)) % 2;
var recoveryPassword = $( '#recoveryPassword' ).val(); var recoveryPassword = $( '#recoveryPassword' ).val();
$.post( $.post(
OC.filePath( 'files_encryption', 'ajax', 'adminrecovery.php' ) OC.filePath( 'files_encryption', 'ajax', 'adminrecovery.php' )
, { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword } , { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword }
, function( data ) { , function( result ) {
if (data.status == "error") { if (result.status === "error") {
alert("Couldn't switch recovery key mode, please check your recovery key password!"); OC.Notification.show(t('admin', result.data.message));
$('input:radio[name="adminEnableRecovery"][value="'+oldStatus.toString()+'"]').attr("checked", "true"); $('input:radio[name="adminEnableRecovery"][value="'+oldStatus.toString()+'"]').attr("checked", "true");
} else { } else {
if (recoveryStatus == "0") { OC.Notification.hide();
if (recoveryStatus === "0") {
$('button:button[name="submitChangeRecoveryKey"]').attr("disabled", "true"); $('button:button[name="submitChangeRecoveryKey"]').attr("disabled", "true");
$('input:password[name="changeRecoveryPassword"]').attr("disabled", "true"); $('input:password[name="changeRecoveryPassword"]').attr("disabled", "true");
$('input:password[name="changeRecoveryPassword"]').val(""); $('input:password[name="changeRecoveryPassword"]').val("");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment