Skip to content

Commit 28c2dc6

Browse files
Use boolean rather than filled for remember (#423)
Co-authored-by: Chris <[email protected]>
1 parent ffc64d1 commit 28c2dc6

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/Actions/RedirectIfTwoFactorAuthenticatable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ protected function twoFactorChallengeResponse($request, $user)
140140
{
141141
$request->session()->put([
142142
'login.id' => $user->getKey(),
143-
'login.remember' => $request->filled('remember'),
143+
'login.remember' => $request->boolean('remember'),
144144
]);
145145

146146
TwoFactorAuthenticationChallenged::dispatch($user);

tests/AuthenticatedSessionControllerTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,35 @@ public function test_two_factor_challenge_can_be_passed_via_code()
296296
->assertSessionMissing('login.id');
297297
}
298298

299+
public function test_two_factor_authentication_preserves_remember_me_selection(): void
300+
{
301+
Event::fake();
302+
303+
app('config')->set('auth.providers.users.model', TestTwoFactorAuthenticationSessionUser::class);
304+
305+
$this->loadLaravelMigrations(['--database' => 'testbench']);
306+
307+
Schema::table('users', function ($table) {
308+
$table->text('two_factor_secret')->nullable();
309+
});
310+
311+
TestTwoFactorAuthenticationSessionUser::forceCreate([
312+
'name' => 'Taylor Otwell',
313+
'email' => '[email protected]',
314+
'password' => bcrypt('secret'),
315+
'two_factor_secret' => 'test-secret',
316+
]);
317+
318+
$response = $this->withoutExceptionHandling()->post('/login', [
319+
'email' => '[email protected]',
320+
'password' => 'secret',
321+
'remember' => false,
322+
]);
323+
324+
$response->assertRedirect('/two-factor-challenge')
325+
->assertSessionHas('login.remember', false);
326+
}
327+
299328
public function test_two_factor_challenge_fails_for_old_otp_and_zero_window()
300329
{
301330
app('config')->set('auth.providers.users.model', TestTwoFactorAuthenticationSessionUser::class);

0 commit comments

Comments
 (0)