Skip to content

Commit 46e5b6c

Browse files
committed
Merge branch 'main' into replace_login_with_fortify
2 parents 65e8687 + d029d08 commit 46e5b6c

File tree

5 files changed

+42
-14
lines changed

5 files changed

+42
-14
lines changed

app/Models/User.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class User extends Authenticatable
3131
*/
3232
protected $hidden = [
3333
'password',
34+
'two_factor_secret',
35+
'two_factory_recovery_codes',
3436
'remember_token',
3537
];
3638

composer.json

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,27 @@
3838
}
3939
},
4040
"scripts": {
41+
"setup": [
42+
"composer install",
43+
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
44+
"@php artisan key:generate",
45+
"@php artisan migrate --force",
46+
"npm install",
47+
"npm run build"
48+
],
49+
"dev": [
50+
"Composer\\Config::disableProcessTimeout",
51+
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
52+
],
53+
"dev:ssr": [
54+
"npm run build:ssr",
55+
"Composer\\Config::disableProcessTimeout",
56+
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"php artisan inertia:start-ssr\" --names=server,queue,logs,ssr --kill-others"
57+
],
58+
"test": [
59+
"@php artisan config:clear --ansi",
60+
"@php artisan test"
61+
],
4162
"post-autoload-dump": [
4263
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
4364
"@php artisan package:discover --ansi"
@@ -53,18 +74,8 @@
5374
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
5475
"@php artisan migrate --graceful --ansi"
5576
],
56-
"dev": [
57-
"Composer\\Config::disableProcessTimeout",
58-
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
59-
],
60-
"dev:ssr": [
61-
"npm run build:ssr",
62-
"Composer\\Config::disableProcessTimeout",
63-
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"php artisan inertia:start-ssr\" --names=server,queue,logs,ssr --kill-others"
64-
],
65-
"test": [
66-
"@php artisan config:clear --ansi",
67-
"@php artisan test"
77+
"pre-package-uninstall": [
78+
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
6879
]
6980
},
7081
"extra": {

database/factories/UserFactory.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public function definition(): array
2929
'email_verified_at' => now(),
3030
'password' => static::$password ??= Hash::make('password'),
3131
'remember_token' => Str::random(10),
32+
'two_factor_secret' => Str::random(10),
33+
'two_factor_recovery_codes' => Str::random(10),
34+
'two_factor_confirmed_at' => now(),
3235
];
3336
}
3437

@@ -41,4 +44,16 @@ public function unverified(): static
4144
'email_verified_at' => null,
4245
]);
4346
}
47+
48+
/**
49+
* Indicate that the model does not have two-factor authentication configured.
50+
*/
51+
public function withoutTwoFactor(): static
52+
{
53+
return $this->state(fn (array $attributes) => [
54+
'two_factor_secret' => null,
55+
'two_factor_recovery_codes' => null,
56+
'two_factor_confirmed_at' => null,
57+
]);
58+
}
4459
}

tests/Feature/Auth/AuthenticationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function test_login_screen_can_be_rendered()
2020

2121
public function test_users_can_authenticate_using_the_login_screen()
2222
{
23-
$user = User::factory()->create();
23+
$user = User::factory()->withoutTwoFactor()->create();
2424

2525
$response = $this->post(route('login.store'), [
2626
'email' => $user->email,

tests/Feature/Settings/TwoFactorAuthenticationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function test_two_factor_settings_page_can_be_rendered()
2323
'confirmPassword' => true,
2424
]);
2525

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

2828
$this->actingAs($user)
2929
->withSession(['auth.password_confirmed_at' => time()])

0 commit comments

Comments
 (0)