Pass `\DateTimeImmutable` to Totp in TotpMultifactorMethod
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 26 Jul 2022 07:44:50 +0000 (09:44 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 26 Jul 2022 07:45:02 +0000 (09:45 +0200)
wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php

index 44502f260857183fee0a0f05688de8244832c4ad..777fb9d28f6822c0dd807de18abda6b402d2c894 100644 (file)
@@ -84,7 +84,7 @@ final class TotpMultifactorMethod implements IMultifactorMethod
                         $totp = $secret->getTotp();
 
                         $minCounter = 0;
-                        if (!$totp->validateTotpCode($field->getValue(), $minCounter, new \DateTime())) {
+                        if (!$totp->validateTotpCode($field->getValue(), $minCounter, new \DateTimeImmutable())) {
                             $field->value('');
                             $field->addValidationError(new FormFieldValidationError(
                                 'invalidCode',
@@ -338,7 +338,7 @@ final class TotpMultifactorMethod implements IMultifactorMethod
 
                         $totp = new Totp($selectedDevice['secret']);
                         $minCounter = $selectedDevice['minCounter'];
-                        if (!$totp->validateTotpCode($field->getValue(), $minCounter, new \DateTime())) {
+                        if (!$totp->validateTotpCode($field->getValue(), $minCounter, new \DateTimeImmutable())) {
                             $field->value('');
                             $field->addValidationError(new FormFieldValidationError(
                                 'invalidCode',