Skip to content

Commit f5f5585

Browse files
add token deleter
1 parent cf6d401 commit f5f5585

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/TokensValidation.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,21 @@ private static function prepareConfig(): void
362362
self::$InvitationBaseUrl = self::$config['InvitationToken']['InvitationBaseUrl'];
363363
}
364364

365+
/**
366+
* @param int $type
367+
* @param string $tokenId
368+
* @return void
369+
*/
370+
private static function deleteToken(int $type, string $tokenId): void
371+
{
372+
if ($type == TokensTypes::AUTHENTICATION_BY_TOKEN || $type == TokensTypes::AUTHENTICATION_BY_COOKIE) {
373+
AuthTokenModel::where('id', $tokenId)->delete();
374+
}
375+
elseif ($type == TokensTypes::CONFIRMATION_CODE) {
376+
ConfirmationTokenModel::where('id', $tokenId)->delete();
377+
}
378+
}
379+
365380
/**
366381
* @param string $userId
367382
* @param integer $type
@@ -608,6 +623,15 @@ public static function checkAuthTokenOrDie(string $fingerPrint = "", ?string $au
608623
}
609624
}
610625

626+
/**
627+
* @param string $tokenId
628+
* @return void
629+
*/
630+
public static function deleteAuthToken(string $tokenId): void
631+
{
632+
self::deleteToken(TokensTypes::AUTHENTICATION_BY_TOKEN, $tokenId);
633+
}
634+
611635
/**
612636
* @param string $code
613637
* @param string|null $encryptedUserId
@@ -704,6 +728,15 @@ public static function checkConfirmationUrlParamsFromGET(array $_GET_ARRAY, stri
704728
->build();
705729
}
706730

731+
/**
732+
* @param string $tokenId
733+
* @return void
734+
*/
735+
public static function deleteConfirmationToken(string $tokenId): void
736+
{
737+
self::deleteToken(TokensTypes::CONFIRMATION_CODE, $tokenId);
738+
}
739+
707740
/**
708741
* @param DateTime $expirationDate
709742
* @return bool

0 commit comments

Comments
 (0)