diff --git a/src/TokensValidation.php b/src/TokensValidation.php index a25584a..79030f5 100644 --- a/src/TokensValidation.php +++ b/src/TokensValidation.php @@ -362,6 +362,21 @@ private static function prepareConfig(): void self::$InvitationBaseUrl = self::$config['InvitationToken']['InvitationBaseUrl']; } + /** + * @param int $type + * @param string $tokenId + * @return void + */ + private static function deleteToken(int $type, string $tokenId): void + { + if ($type == TokensTypes::AUTHENTICATION_BY_TOKEN || $type == TokensTypes::AUTHENTICATION_BY_COOKIE) { + AuthTokenModel::where('id', $tokenId)->delete(); + } + elseif ($type == TokensTypes::CONFIRMATION_CODE) { + ConfirmationTokenModel::where('id', $tokenId)->delete(); + } + } + /** * @param string $userId * @param integer $type @@ -608,6 +623,15 @@ public static function checkAuthTokenOrDie(string $fingerPrint = "", ?string $au } } + /** + * @param string $tokenId + * @return void + */ + public static function deleteAuthToken(string $tokenId): void + { + self::deleteToken(TokensTypes::AUTHENTICATION_BY_TOKEN, $tokenId); + } + /** * @param string $code * @param string|null $encryptedUserId @@ -704,6 +728,15 @@ public static function checkConfirmationUrlParamsFromGET(array $_GET_ARRAY, stri ->build(); } + /** + * @param string $tokenId + * @return void + */ + public static function deleteConfirmationToken(string $tokenId): void + { + self::deleteToken(TokensTypes::CONFIRMATION_CODE, $tokenId); + } + /** * @param DateTime $expirationDate * @return bool