@@ -612,9 +612,10 @@ public static function checkAuthTokenOrDie(string $fingerPrint = "", ?string $au
612
612
* @param string $code
613
613
* @param string|null $encryptedUserId
614
614
* @param string $whatFor
615
+ * @param bool $deleteAfterCheck
615
616
* @return ConfirmationTokenResponse
616
617
*/
617
- public static function checkConfirmationCode (string $ code , string $ encryptedUserId = null , string $ whatFor = "default " ): ConfirmationTokenResponse
618
+ public static function checkConfirmationCode (string $ code , string $ encryptedUserId = null , string $ whatFor = "default " , bool $ deleteAfterCheck = true ): ConfirmationTokenResponse
618
619
{
619
620
$ confirmationTokenResultsBuilder = ConfirmationTokenResponse::builder ()
620
621
->setValidationSucceed (false );
@@ -638,7 +639,9 @@ public static function checkConfirmationCode(string $code, string $encryptedUser
638
639
if ($ confirmationTokenModel ->whatFor == $ whatFor || $ whatFor == "default " ) {
639
640
$ confirmationTokenResultsBuilder ->setValidationSucceed (true );
640
641
$ confirmationTokenResultsBuilder ->withWhatFor ($ whatFor );
641
- ConfirmationTokenModel::find ($ confirmationTokenModel ->id )->delete ();
642
+ if ($ deleteAfterCheck ) {
643
+ ConfirmationTokenModel::find ($ confirmationTokenModel ->id )->delete ();
644
+ }
642
645
return $ confirmationTokenResultsBuilder ->build ();
643
646
}
644
647
else {
@@ -663,14 +666,15 @@ public static function checkConfirmationCode(string $code, string $encryptedUser
663
666
/**
664
667
* @param string $url
665
668
* @param string $whatFor
669
+ * @param bool $deleteAfterCheck
666
670
* @return ConfirmationTokenResponse
667
671
*/
668
- public static function checkConfirmationUrl (string $ url , string $ whatFor = "default " ): ConfirmationTokenResponse
672
+ public static function checkConfirmationUrl (string $ url , string $ whatFor = "default " , bool $ deleteAfterCheck = true ): ConfirmationTokenResponse
669
673
{
670
674
/** @var UserIdAndToken $userIdAndToken */
671
675
$ userIdAndToken = call_user_func_array ([new TokensValidation::$ ConfirmationUrlBuilder (), 'getUserIdAndTokenFromUrl ' ], [$ url ]);
672
676
if ($ userIdAndToken != null ) {
673
- return self ::checkConfirmationCode ($ userIdAndToken ->getToken (), $ userIdAndToken ->getUserId (), $ whatFor );
677
+ return self ::checkConfirmationCode ($ userIdAndToken ->getToken (), $ userIdAndToken ->getUserId (), $ whatFor, $ deleteAfterCheck );
674
678
}
675
679
return ConfirmationTokenResponse::builder ()
676
680
->setException (new Exception ("can't get userIdAndToken " ))
@@ -682,14 +686,15 @@ public static function checkConfirmationUrl(string $url, string $whatFor = "defa
682
686
/**
683
687
* @param array $_GET_ARRAY
684
688
* @param string $whatFor
689
+ * @param bool $deleteAfterCheck
685
690
* @return ConfirmationTokenResponse
686
691
*/
687
- public static function checkConfirmationUrlParamsFromGET (array $ _GET_ARRAY , string $ whatFor = "default " ): ConfirmationTokenResponse
692
+ public static function checkConfirmationUrlParamsFromGET (array $ _GET_ARRAY , string $ whatFor = "default " , bool $ deleteAfterCheck = true ): ConfirmationTokenResponse
688
693
{
689
694
/** @var UserIdAndToken $userIdAndToken */
690
695
$ userIdAndToken = call_user_func_array ([new TokensValidation::$ ConfirmationUrlBuilder (), 'getUserIdAndTokenFromGET ' ], [$ _GET_ARRAY ]);
691
696
if ($ userIdAndToken != null ) {
692
- return self ::checkConfirmationCode ($ userIdAndToken ->getToken (), $ userIdAndToken ->getUserId (), $ whatFor );
697
+ return self ::checkConfirmationCode ($ userIdAndToken ->getToken (), $ userIdAndToken ->getUserId (), $ whatFor, $ deleteAfterCheck );
693
698
}
694
699
return ConfirmationTokenResponse::builder ()
695
700
->setException (new Exception ("can't get userIdAndToken " ))
0 commit comments