From 5ca02ed4419793344bd92849446f499bf271c121 Mon Sep 17 00:00:00 2001 From: nilsteampassnet Date: Sat, 15 Apr 2023 12:13:27 +0200 Subject: [PATCH] 3.0.6 Improved "user regenerate keys" feature --- includes/core/load.js.php | 1 + .../background_tasks___user_keys_creation.php | 10 ++++++++-- sources/main.functions.php | 17 +++++++++-------- sources/main.queries.php | 1 + 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/includes/core/load.js.php b/includes/core/load.js.php index 081e8f172..22cd4ac16 100755 --- a/includes/core/load.js.php +++ b/includes/core/load.js.php @@ -1933,6 +1933,7 @@ function(data) { // We need to finalize user public/private keys $('#user_not_ready').addClass('hidden'); + $("#warningModalButtonAction").removeClass('hidden'); $('#user_not_ready_progress').html(''); toastr.success( data.message, diff --git a/scripts/background_tasks___user_keys_creation.php b/scripts/background_tasks___user_keys_creation.php index 8bc18a6da..2dabe502f 100755 --- a/scripts/background_tasks___user_keys_creation.php +++ b/scripts/background_tasks___user_keys_creation.php @@ -950,7 +950,10 @@ function cronContinueReEncryptingUserSharekeysStep6( ); if ($userInfo['auth_type'] === 'local') { - if (isset($extra_arguments['send_email']) === true && (int) $extra_arguments['send_email'] === 1) { + if ( + (isset($extra_arguments['send_email']) === true && (int) $extra_arguments['send_email'] === 1) + || (isset($extra_arguments['send_email']) === false) + ) { // Send email to user sendMailToUser( filter_var($userInfo['email'], FILTER_SANITIZE_FULL_SPECIAL_CHARS), @@ -982,7 +985,10 @@ function cronContinueReEncryptingUserSharekeysStep6( ); } else { if ($userInfo['special'] === 'user_added_from_ldap') { - if (isset($extra_arguments['send_email']) === true && (int) $extra_arguments['send_email'] === 1) { + if ( + (isset($extra_arguments['send_email']) === true && (int) $extra_arguments['send_email'] === 1) + || (isset($extra_arguments['send_email']) === false) + ) { sendMailToUser( filter_var($userInfo['email'], FILTER_SANITIZE_FULL_SPECIAL_CHARS), langHdl('email_body_user_added_from_ldap_encryption_code'), diff --git a/sources/main.functions.php b/sources/main.functions.php index 825fc5243..0e98f0583 100755 --- a/sources/main.functions.php +++ b/sources/main.functions.php @@ -3905,7 +3905,8 @@ function upgradeRequired(): bool * @param boolean $deleteExistingKeys * @param boolean $sendEmailToUser * @param boolean $encryptWithUserPassword - * @return boolean + * @param integer $nbItemsToTreat + * @return string */ function handleUserKeys( int $userId, @@ -3967,7 +3968,7 @@ function handleUserKeys( 'task' => json_encode([ 'step' => 'step0', 'index' => 0, - 'nb' => isset($SETTINGS['maximum_number_of_items_to_treat']) === true ? $SETTINGS['maximum_number_of_items_to_treat'] : NUMBER_ITEMS_IN_BATCH, + 'nb' => empty($nbItemsToTreat) === false ? $nbItemsToTreat : NUMBER_ITEMS_IN_BATCH, ]), ) ); @@ -3980,7 +3981,7 @@ function handleUserKeys( 'task' => json_encode([ 'step' => 'step1', 'index' => 0, - 'nb' => isset($SETTINGS['maximum_number_of_items_to_treat']) === true ? $SETTINGS['maximum_number_of_items_to_treat'] : NUMBER_ITEMS_IN_BATCH, + 'nb' => empty($nbItemsToTreat) === false ? $nbItemsToTreat : NUMBER_ITEMS_IN_BATCH, ]), ) ); @@ -3993,7 +3994,7 @@ function handleUserKeys( 'task' => json_encode([ 'step' => 'step2', 'index' => 0, - 'nb' => isset($SETTINGS['maximum_number_of_items_to_treat']) === true ? $SETTINGS['maximum_number_of_items_to_treat'] : NUMBER_ITEMS_IN_BATCH, + 'nb' => empty($nbItemsToTreat) === false ? $nbItemsToTreat : NUMBER_ITEMS_IN_BATCH, ]), ) ); @@ -4006,7 +4007,7 @@ function handleUserKeys( 'task' => json_encode([ 'step' => 'step3', 'index' => 0, - 'nb' => isset($SETTINGS['maximum_number_of_items_to_treat']) === true ? $SETTINGS['maximum_number_of_items_to_treat'] : NUMBER_ITEMS_IN_BATCH, + 'nb' => empty($nbItemsToTreat) === false ? $nbItemsToTreat : NUMBER_ITEMS_IN_BATCH, ]), ) ); @@ -4019,7 +4020,7 @@ function handleUserKeys( 'task' => json_encode([ 'step' => 'step4', 'index' => 0, - 'nb' => isset($SETTINGS['maximum_number_of_items_to_treat']) === true ? $SETTINGS['maximum_number_of_items_to_treat'] : NUMBER_ITEMS_IN_BATCH, + 'nb' => empty($nbItemsToTreat) === false ? $nbItemsToTreat : NUMBER_ITEMS_IN_BATCH, ]), ) ); @@ -4032,7 +4033,7 @@ function handleUserKeys( 'task' => json_encode([ 'step' => 'step5', 'index' => 0, - 'nb' => isset($SETTINGS['maximum_number_of_items_to_treat']) === true ? $SETTINGS['maximum_number_of_items_to_treat'] : NUMBER_ITEMS_IN_BATCH, + 'nb' => empty($nbItemsToTreat) === false ? $nbItemsToTreat : NUMBER_ITEMS_IN_BATCH, ]), ) ); @@ -4045,7 +4046,7 @@ function handleUserKeys( 'task' => json_encode([ 'step' => 'step6', 'index' => 0, - 'nb' => isset($SETTINGS['maximum_number_of_items_to_treat']) === true ? $SETTINGS['maximum_number_of_items_to_treat'] : NUMBER_ITEMS_IN_BATCH, + 'nb' => empty($nbItemsToTreat) === false ? $nbItemsToTreat : NUMBER_ITEMS_IN_BATCH, ]), ) ); diff --git a/sources/main.queries.php b/sources/main.queries.php index 25ed8ce2a..aec9f7d43 100755 --- a/sources/main.queries.php +++ b/sources/main.queries.php @@ -516,6 +516,7 @@ function keyHandler(string $post_type, /*php8 array|null|string */$dataReceived, (bool) filter_var($dataReceived['delete_existing_keys'], FILTER_VALIDATE_BOOLEAN), (bool) filter_var($dataReceived['send_email_to_user'], FILTER_VALIDATE_BOOLEAN), (bool) filter_var($dataReceived['encrypt_with_user_pwd'], FILTER_VALIDATE_BOOLEAN), + (int) isset($SETTINGS['maximum_number_of_items_to_treat']) === true ? $SETTINGS['maximum_number_of_items_to_treat'] : '', ); /*