diff options
-rw-r--r-- | apps/files_encryption/js/settings-admin.js | 36 | ||||
-rw-r--r-- | apps/files_encryption/templates/settings-admin.php | 28 |
2 files changed, 37 insertions, 27 deletions
diff --git a/apps/files_encryption/js/settings-admin.js b/apps/files_encryption/js/settings-admin.js index 6647c621e7b..82fdb517088 100644 --- a/apps/files_encryption/js/settings-admin.js +++ b/apps/files_encryption/js/settings-admin.js @@ -1,6 +1,6 @@ /** - * Copyright (c) 2013, Sam Tuke <samtuke@owncloud.com>, Robin Appelman - * <icewind1991@gmail.com> + * 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. */ @@ -31,22 +31,23 @@ $(document).ready(function(){ // Trigger ajax on recoveryAdmin status change var enabledStatus = $('#adminEnableRecovery').val(); - $('input:password[name="recoveryPassword"]').keyup(function(event) { - var recoveryPassword = $( '#recoveryPassword' ).val(); + $('input:password[name="encryptionRecoveryPassword"]').keyup(function(event) { + var recoveryPassword = $( '#encryptionRecoveryPassword' ).val(); + var recoveryPasswordRepeated = $( '#repeatEncryptionRecoveryPassword' ).val(); var checkedButton = $('input:radio[name="adminEnableRecovery"]:checked').val(); var uncheckedValue = (1+parseInt(checkedButton)) % 2; - if (recoveryPassword != '' ) { + if (recoveryPassword !== '' && recoveryPassword === recoveryPasswordRepeated) { $('input:radio[name="adminEnableRecovery"][value="'+uncheckedValue.toString()+'"]').removeAttr("disabled"); } else { $('input:radio[name="adminEnableRecovery"][value="'+uncheckedValue.toString()+'"]').attr("disabled", "true"); } }); - $( 'input:radio[name="adminEnableRecovery"]' ).change( + $( 'input:radio[name="adminEnableRecovery"]' ).change( function() { var recoveryStatus = $( this ).val(); var oldStatus = (1+parseInt(recoveryStatus)) % 2; - var recoveryPassword = $( '#recoveryPassword' ).val(); + var recoveryPassword = $( '#encryptionRecoveryPassword' ).val(); $.post( OC.filePath( 'files_encryption', 'ajax', 'adminrecovery.php' ) , { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword } @@ -57,11 +58,10 @@ $(document).ready(function(){ } else { OC.Notification.hide(); if (recoveryStatus === "0") { - $('button:button[name="submitChangeRecoveryKey"]').attr("disabled", "true"); - $('input:password[name="changeRecoveryPassword"]').attr("disabled", "true"); - $('input:password[name="changeRecoveryPassword"]').val(""); + $('p[name="changeRecoveryPasswordBlock"]').attr("class", "hidden"); } else { - $('input:password[name="changeRecoveryPassword"]').removeAttr("disabled"); + $('input:password[name="changeRecoveryPassword"]').val(""); + $('p[name="changeRecoveryPasswordBlock"]').removeAttr("class"); } } } @@ -72,9 +72,11 @@ $(document).ready(function(){ // change recovery password $('input:password[name="changeRecoveryPassword"]').keyup(function(event) { - var oldRecoveryPassword = $('input:password[id="oldRecoveryPassword"]').val(); - var newRecoveryPassword = $('input:password[id="newRecoveryPassword"]').val(); - if (newRecoveryPassword != '' && oldRecoveryPassword != '' ) { + var oldRecoveryPassword = $('#oldEncryptionRecoveryPassword').val(); + var newRecoveryPassword = $('#newEncryptionRecoveryPassword').val(); + var newRecoveryPasswordRepeated = $('#repeatedNewEncryptionRecoveryPassword').val(); + console.log("new: " + newRecoveryPassword + " - repeated: " + newRecoveryPasswordRepeated); + if (newRecoveryPassword !== '' && oldRecoveryPassword !== '' && newRecoveryPassword === newRecoveryPasswordRepeated) { $('button:button[name="submitChangeRecoveryKey"]').removeAttr("disabled"); } else { $('button:button[name="submitChangeRecoveryKey"]').attr("disabled", "true"); @@ -83,8 +85,8 @@ $(document).ready(function(){ $('button:button[name="submitChangeRecoveryKey"]').click(function() { - var oldRecoveryPassword = $('input:password[id="oldRecoveryPassword"]').val(); - var newRecoveryPassword = $('input:password[id="newRecoveryPassword"]').val(); + var oldRecoveryPassword = $('#oldEncryptionRecoveryPassword').val(); + var newRecoveryPassword = $('#newEncryptionRecoveryPassword').val(); OC.msg.startSaving('#encryption .msg'); $.post( OC.filePath( 'files_encryption', 'ajax', 'changeRecoveryPassword.php' ) @@ -98,5 +100,5 @@ $(document).ready(function(){ } ); }); - + }); diff --git a/apps/files_encryption/templates/settings-admin.php b/apps/files_encryption/templates/settings-admin.php index f5f7582c2a6..3a6adc09f4b 100644 --- a/apps/files_encryption/templates/settings-admin.php +++ b/apps/files_encryption/templates/settings-admin.php @@ -10,14 +10,17 @@ <?php p($l->t("Enable recovery key (allow to recover users files in case of password loss):")); ?> <br/> <br/> - <input type="password" name="recoveryPassword" id="recoveryPassword"/> + <input type="password" name="encryptionRecoveryPassword" id="encryptionRecoveryPassword"/> <label for="recoveryPassword"><?php p($l->t("Recovery key password")); ?></label> <br/> + <input type="password" name="encryptionRecoveryPassword" id="repeatEncryptionRecoveryPassword"/> + <label for="repeatEncryptionRecoveryPassword"><?php p($l->t("Repeat Recovery key password")); ?></label> + <br/> <input type='radio' name='adminEnableRecovery' value='1' - <?php echo($_["recoveryEnabled"] == 1 ? 'checked="checked"' : 'disabled'); ?> /> + <?php echo($_["recoveryEnabled"] === '1' ? 'checked="checked"' : 'disabled'); ?> /> <?php p($l->t("Enabled")); ?> <br/> @@ -25,27 +28,32 @@ type='radio' name='adminEnableRecovery' value='0' - <?php echo($_["recoveryEnabled"] == 0 ? 'checked="checked"' : 'disabled'); ?> /> + <?php echo($_["recoveryEnabled"] === '0' ? 'checked="checked"' : 'disabled'); ?> /> <?php p($l->t("Disabled")); ?> </p> <br/><br/> - <p> + <p name="changeRecoveryPasswordBlock" <?php if ($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>> <strong><?php p($l->t("Change recovery key password:")); ?></strong> <br/><br/> <input type="password" name="changeRecoveryPassword" - id="oldRecoveryPassword" - <?php echo($_["recoveryEnabled"] == 0 ? 'disabled' : ''); ?> /> - <label for="oldRecoveryPassword"><?php p($l->t("Old Recovery key password")); ?></label> + id="oldEncryptionRecoveryPassword" + <label for="oldEncryptionRecoveryPassword"><?php p($l->t("Old Recovery key password")); ?></label> + <br/> + <br/> + <input + type="password" + name="changeRecoveryPassword" + id="newEncryptionRecoveryPassword" + <label for="newEncryptionRecoveryPassword"><?php p($l->t("New Recovery key password")); ?></label> <br/> <input type="password" name="changeRecoveryPassword" - id="newRecoveryPassword" - <?php echo($_["recoveryEnabled"] == 0 ? 'disabled' : ''); ?> /> - <label for="newRecoveryPassword"><?php p($l->t("New Recovery key password")); ?></label> + id="repeatedNewEncryptionRecoveryPassword" + <label for="repeatEncryptionRecoveryPassword"><?php p($l->t("Repeat New Recovery key password")); ?></label> <br/> <button type="button" |