@@ -210,6 +210,7 @@ public function bootstrapYubikeySecondFactor(
210210 ): void {
211211 $ this ->assertNotForgotten ();
212212 $ this ->assertUserMayAddSecondFactor ($ maxNumberOfTokens );
213+ $ this ->assertTokenNotAlreadyRegistered (new SecondFactorType ('yubikey ' ), $ yubikeyPublicId );
213214
214215 $ this ->apply (
215216 new YubikeySecondFactorBootstrappedEvent (
@@ -234,6 +235,7 @@ public function provePossessionOfYubikey(
234235 ): void {
235236 $ this ->assertNotForgotten ();
236237 $ this ->assertUserMayAddSecondFactor ($ maxNumberOfTokens );
238+ $ this ->assertTokenNotAlreadyRegistered (new SecondFactorType ('yubikey ' ), $ yubikeyPublicId );
237239
238240 if ($ emailVerificationRequired ) {
239241 $ emailVerificationNonce = TokenGenerator::generateNonce ();
@@ -373,6 +375,7 @@ public function provePossessionOfGssf(
373375 ): void {
374376 $ this ->assertNotForgotten ();
375377 $ this ->assertUserMayAddSecondFactor ($ maxNumberOfTokens );
378+ $ this ->assertTokenNotAlreadyRegistered (new SecondFactorType ($ provider ->getStepupProvider ()), $ secondFactorId );
376379
377380 if ($ emailVerificationRequired ) {
378381 $ emailVerificationNonce = TokenGenerator::generateNonce ();
@@ -422,6 +425,7 @@ public function provePossessionOfU2fDevice(
422425 ): void {
423426 $ this ->assertNotForgotten ();
424427 $ this ->assertUserMayAddSecondFactor ($ maxNumberOfTokens );
428+ $ this ->assertTokenNotAlreadyRegistered (new SecondFactorType ('u2f ' ), $ keyHandle );
425429
426430 if ($ emailVerificationRequired ) {
427431 $ emailVerificationNonce = TokenGenerator::generateNonce ();
@@ -1546,7 +1550,7 @@ private function assertTokenNotAlreadyRegistered(SecondFactorType $type, SecondF
15461550 {
15471551 foreach ($ this ->unverifiedSecondFactors as $ unverified ) {
15481552 if ($ unverified ->typeAndIdentifierAreEqual ($ type , $ identifier )) {
1549- throw new DomainException ("The second factor was already registered as a unverified second factor " );
1553+ throw new DomainException ("The second factor was already registered as an unverified second factor " );
15501554 }
15511555 }
15521556 foreach ($ this ->verifiedSecondFactors as $ verified ) {
0 commit comments