Skip to content

Commit

Permalink
3.0.6
Browse files Browse the repository at this point in the history
Improved "user regenerate keys" feature
  • Loading branch information
nilsteampassnet committed Apr 15, 2023
1 parent cc8d73f commit 5ca02ed
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions includes/core/load.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 8 additions & 2 deletions scripts/background_tasks___user_keys_creation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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'),
Expand Down
17 changes: 9 additions & 8 deletions sources/main.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
]),
)
);
Expand All @@ -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,
]),
)
);
Expand All @@ -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,
]),
)
);
Expand All @@ -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,
]),
)
);
Expand All @@ -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,
]),
)
);
Expand All @@ -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,
]),
)
);
Expand All @@ -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,
]),
)
);
Expand Down
1 change: 1 addition & 0 deletions sources/main.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] : '',
);

/*
Expand Down

0 comments on commit 5ca02ed

Please sign in to comment.