From b55dbf92241938f918df37fc9bfc483d127c9064 Mon Sep 17 00:00:00 2001 From: nilsteampassnet Date: Sun, 11 Sep 2022 18:03:48 +0200 Subject: [PATCH] 3.0.0.18 Fixes --- .github/FUNDING.yml | 4 ++-- includes/js/functions.js | 9 ++++++++- pages/users.js.php | 27 ++++++++++++++------------- sources/users.queries.php | 33 ++++++++++++++++++++++----------- 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index e01ce2240..b8d942adc 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,5 +1,5 @@ # These are supported funding model platforms github: nilsteampassnet -patreon: teampass -open_collective: teampass +# patreon: teampass +# open_collective: teampass diff --git a/includes/js/functions.js b/includes/js/functions.js index fd230a83d..a55f98bd6 100644 --- a/includes/js/functions.js +++ b/includes/js/functions.js @@ -25,7 +25,14 @@ function countdown() $('.countdown-icon') .addClass('fas fa-history') .removeClass('far fa-clock'); - return; + + $(this).delay(1000).queue(function() + { + countdown(); + $(this).dequeue(); + }); + + return false; } // Continue diff --git a/pages/users.js.php b/pages/users.js.php index df4b59804..3811f955a 100644 --- a/pages/users.js.php +++ b/pages/users.js.php @@ -2524,13 +2524,15 @@ function(data) { var data = { 'action': 'stepFinishing', 'user_id': userId, + 'user_new_otp': userTemporaryCode, } - console.log("Finishing user creation from LDAP") + //console.log("Finishing user creation from LDAP") console.log(data) + // Do query $.post( "sources/users.queries.php", { - type: "finishing_user_creation_from_ldap", + type: "finishing_user_keys_creation", data: prepareExchangedData(JSON.stringify(data), 'encode', ''), key: '' }, @@ -2538,20 +2540,19 @@ function(data) { data = prepareExchangedData(data, "decode", ""); console.log(data); console.log("---"); - } - ); - - // refresh the list of users in LDAP not added in Teampass - refreshListUsersLDAP(); + + // refresh the list of users in LDAP not added in Teampass + refreshListUsersLDAP(); - // Rrefresh list of users in Teampass - oTable.ajax.reload(); + // Rrefresh list of users in Teampass + oTable.ajax.reload(); - $('#warningModal').modal('hide'); + $('#warningModal').modal('hide'); - // restart time expiration counter - ProcessInProgress = false; - console.log('TOUT EST TERMINE') + // restart time expiration counter + ProcessInProgress = false; + } + ); } return dfd.promise(); } diff --git a/sources/users.queries.php b/sources/users.queries.php index ae7680026..a9181fdf4 100644 --- a/sources/users.queries.php +++ b/sources/users.queries.php @@ -2760,9 +2760,9 @@ break; /* - * ADD USER FROM LDAP - FINISHING - */ - case 'finishing_user_creation_from_ldap': + * ADD USER KEYS CREATION - FINISHING + */ + case 'finishing_user_keys_creation': // Check KEY if ($post_key !== $_SESSION['key']) { echo prepareExchangedData( @@ -2785,6 +2785,7 @@ // Prepare variables $post_userId = filter_var($dataReceived['user_id'], FILTER_SANITIZE_STRING); + $post_otp = filter_var($dataReceived['user_new_otp'], FILTER_SANITIZE_STRING); DB::update( prefixTable('users'), @@ -2795,6 +2796,24 @@ $post_userId ); + // Send mail to user with new OTP + $userInfo = DB::queryFirstRow( + 'SELECT email + FROM ' . prefixTable('users') . ' + WHERE id = %i', + $post_userId + ); + sendEmail( + 'TEAMPASS - ' . langHdl('temporary_encryption_code'), + str_replace( + array('#enc_code#'), + array($post_otp), + langHdl('email_body_user_added_from_ldap_encryption_code') + ), + $userInfo['email'], + $SETTINGS + ); + echo prepareExchangedData( $SETTINGS['cpassman_dir'], @@ -3379,16 +3398,8 @@ if ($userInfo['auth_type'] === 'local') { $values['special'] = 'generate-keys'; - /*array_push( - $values, - array('special' => 'generate-keys') - );*/ } elseif ($userInfo['auth_type'] === 'ldap') { $values['special'] = 'user_added_from_ldap'; - /*array_push( - $values, - array('special' => 'user_added_from_ldap') - );*/ } // update profil