File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -15,14 +15,16 @@ class FailedTwoFactorLoginResponse implements FailedTwoFactorLoginResponseContra
15
15
*/
16
16
public function toResponse ($ request )
17
17
{
18
- $ message = __ ('The provided two factor authentication code was invalid. ' );
18
+ [$ key , $ message ] = $ request ->has ('recovery_code ' )
19
+ ? ['recovery_code ' , __ ('The provided two factor recovery code was invalid. ' )]
20
+ : ['code ' , __ ('The provided two factor authentication code was invalid. ' )];
19
21
20
22
if ($ request ->wantsJson ()) {
21
23
throw ValidationException::withMessages ([
22
- ' code ' => [$ message ],
24
+ $ key => [$ message ],
23
25
]);
24
26
}
25
27
26
- return redirect ()->route ('two-factor.login ' )->withErrors ([' code ' => $ message ]);
28
+ return redirect ()->route ('two-factor.login ' )->withErrors ([$ key => $ message ]);
27
29
}
28
30
}
Original file line number Diff line number Diff line change @@ -328,7 +328,8 @@ public function test_two_factor_challenge_fails_for_old_otp_and_zero_window()
328
328
]);
329
329
330
330
$ response ->assertRedirect ('/two-factor-challenge ' )
331
- ->assertSessionHas ('login.id ' );
331
+ ->assertSessionHas ('login.id ' )
332
+ ->assertSessionHasErrors (['code ' ]);
332
333
}
333
334
334
335
public function test_two_factor_challenge_can_be_passed_via_recovery_code ()
@@ -380,7 +381,8 @@ public function test_two_factor_challenge_can_fail_via_recovery_code()
380
381
]);
381
382
382
383
$ response ->assertRedirect ('/two-factor-challenge ' )
383
- ->assertSessionHas ('login.id ' );
384
+ ->assertSessionHas ('login.id ' )
385
+ ->assertSessionHasErrors (['recovery_code ' ]);
384
386
$ this ->assertNull (Auth::getUser ());
385
387
}
386
388
You can’t perform that action at this time.
0 commit comments