Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function definition(): array
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'two_factor_secret' => Str::random(10),
'two_factor_recovery_codes' => Str::random(10),
'two_factor_confirmed_at' => now(),
];
}

Expand All @@ -41,4 +44,16 @@ public function unverified(): static
'email_verified_at' => null,
]);
}

/**
* Indicate that the model does not have two-factor authentication configured.
*/
public function withoutTwoFactor(): static
{
return $this->state(fn (array $attributes) => [
'two_factor_secret' => null,
'two_factor_recovery_codes' => null,
'two_factor_confirmed_at' => null,
]);
}
}
2 changes: 1 addition & 1 deletion tests/Feature/Auth/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function test_login_screen_can_be_rendered()

public function test_users_can_authenticate_using_the_login_screen()
{
$user = User::factory()->create();
$user = User::factory()->withoutTwoFactor()->create();

$response = $this->post(route('login.store'), [
'email' => $user->email,
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Settings/TwoFactorAuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function test_two_factor_settings_page_can_be_rendered()
'confirmPassword' => true,
]);

$user = User::factory()->create();
$user = User::factory()->withoutTwoFactor()->create();

$this->actingAs($user)
->withSession(['auth.password_confirmed_at' => time()])
Expand Down
Loading