diff --git a/include/lucidAuth.functions.php b/include/lucidAuth.functions.php index 2c6910c..bf022e8 100644 --- a/include/lucidAuth.functions.php +++ b/include/lucidAuth.functions.php @@ -208,7 +208,7 @@ function purgeTokens(int $userID, int $maximumTokenAge) { $pdoQuery->execute(array_merge($defunctTokens, $expiredTokens)); if ($settings->Debug['LogToFile']) { - file_put_contents('../purgeToken.log', (new DateTime())->format('Y-m-d\TH:i:s.u') . ' --- Garbage collection succeeded (' . $userID . ' => ' . $pdoQuery->rowCount() . ')' . PHP_EOL, FILE_APPEND); + file_put_contents('../purgeToken.log', (new DateTime())->format('Y-m-d\TH:i:s.u') . ' --- Garbage collection succeeded (' . $userID . ' => #' . $pdoQuery->rowCount() . ')' . PHP_EOL, FILE_APPEND); } return [ @@ -224,4 +224,35 @@ function purgeTokens(int $userID, int $maximumTokenAge) { } } +function deleteToken(array $tokenIDs, int $userID) { + try { + // Sadly, PDO does not support named parameters in constructions like 'IN ( :array )' + // instead, the supported syntax is unnamed placeholders like 'IN (?, ?, ?, ...)' + $pdoQuery = $pdoDB->prepare(' + DELETE FROM SecureToken + WHERE SecureToken.Id IN (' . implode( ',', array_fill(0, count($tokenIDs), '?')) . ') + AND SecureToken.UserId = :userid + '); + $pdoQuery->execute($tokenIDs,[ + ':userid' => (int) $userID + ]); + + if ($settings->Debug['LogToFile']) { + file_put_contents('../deleteToken.log', (new DateTime())->format('Y-m-d\TH:i:s.u') . ' --- Successfully deleted specific token(s) (' . $userID . ' => #' . $pdoQuery->rowCount() . ')' . PHP_EOL, FILE_APPEND); + } + + return [ + 'status' => 'Success', + 'amount' => $pdoQuery->rowCount() + ]; + } catch (Exception $e) { + if ($settings->Debug['LogToFile']) { + file_put_contents('../deleteToken.log', (new DateTime())->format('Y-m-d\TH:i:s.u') . ' --- Failed deleting specific token(s) (' . $userID . ' => ' . $e . ')' . PHP_EOL, FILE_APPEND); + } + + return ['status' => 'Fail', 'reason' => $e]; + } + +} + ?> \ No newline at end of file diff --git a/public/lucidAuth.manage.php b/public/lucidAuth.manage.php index 7f17ee9..263dc02 100644 --- a/public/lucidAuth.manage.php +++ b/public/lucidAuth.manage.php @@ -23,6 +23,7 @@ try { $JWTPayload = JWT::decode($row['Value'], base64_decode($settings->JWT['PrivateKey_base64']), $settings->JWT['Algorithm']); $storedTokens[] = [ + 'tid' => $row['Id'], 'iat' => $JWTPayload->iat, 'iss' => $JWTPayload->iss, 'fp' => $JWTPayload->fp diff --git a/public/misc/script.manage.js b/public/misc/script.manage.js index e03689b..8c77255 100644 --- a/public/misc/script.manage.js +++ b/public/misc/script.manage.js @@ -1,3 +1,25 @@ +jQuery.fn.inlineConfirm = function() { + return this.on('click', function(event) { + sessionID = $(this).data('sessionid'); +// event.preventDefault(); + $(this).off('click').parent().empty().append( + $('