Update Demo seeder to multi-user schema

This commit is contained in:
Bubka 2023-04-14 19:04:23 +02:00
parent 3413d31a3c
commit 5a1722535a

View File

@ -16,19 +16,20 @@ class DemoSeeder extends Seeder
*/
public function run()
{
User::create([
$user = User::create([
'name' => 'demo',
'email' => 'demo@2fauth.app',
'password' => bcrypt('demo'),
'is_admin' => 1,
]);
$groupSocialNetwork = Group::create([
$groupSocialNetwork = $user->groups()->create([
'name' => 'Social Networks',
]);
$groupSocialNetwork->twofaccounts()->createMany([
$user->twofaccounts()->createMany([
[
'group_id' => $groupSocialNetwork->id,
'otp_type' => 'totp',
'account' => 'johndoe@facebook.com',
'service' => 'Facebook',
@ -40,6 +41,7 @@ public function run()
'legacy_uri' => 'otpauth://totp/Facebook:johndoe@facebook.com?secret=A4GRFTVVRBGY7UIW',
],
[
'group_id' => $groupSocialNetwork->id,
'otp_type' => 'totp',
'service' => 'Twitter',
'account' => '@john',
@ -51,6 +53,7 @@ public function run()
'legacy_uri' => 'otpauth://totp/Twitter:@john?secret=A2GRFTVVRBGY7UIW',
],
[
'group_id' => $groupSocialNetwork->id,
'otp_type' => 'totp',
'service' => 'Instagram',
'account' => '@johndoe',
@ -62,6 +65,7 @@ public function run()
'legacy_uri' => 'otpauth://totp/Instagram:@johndoe?secret=A6GRFTVVRBGY7UIW',
],
[
'group_id' => $groupSocialNetwork->id,
'otp_type' => 'totp',
'service' => 'LinkedIn',
'account' => '@johndoe',
@ -74,11 +78,12 @@ public function run()
]
]);
$groupECommerce = Group::create([
$groupECommerce = $user->groups()->create([
'name' => 'eCommerce',
]);
$groupECommerce->twofaccounts()->create([
$user->twofaccounts()->create([
'group_id' => $groupECommerce->id,
'otp_type' => 'totp',
'account' => 'johndoe',
'service' => 'Amazon',
@ -90,7 +95,8 @@ public function run()
'legacy_uri' => 'otpauth://totp/Amazon:johndoe?secret=A7GRFTVVRBGY7UIW',
]);
TwoFAccount::create([
$user->twofaccounts()->createMany([
[
'otp_type' => 'totp',
'account' => 'john.doe@icloud.com',
'service' => 'Apple',
@ -100,9 +106,8 @@ public function run()
'period' => 30,
'icon' => 'apple.png',
'legacy_uri' => 'otpauth://totp/Apple:john.doe@icloud.com?secret=A2GRFTVVRBGY7UIW',
]);
TwoFAccount::create([
],
[
'otp_type' => 'totp',
'account' => 'john.doe',
'service' => 'Dropbox',
@ -112,9 +117,8 @@ public function run()
'period' => 30,
'icon' => 'dropbox.png',
'legacy_uri' => 'otpauth://totp/Dropbox:john.doe?secret=A3GRFTVVRBGY7UIW',
]);
TwoFAccount::create([
],
[
'otp_type' => 'totp',
'account' => '@john',
'service' => 'Github',
@ -124,9 +128,8 @@ public function run()
'period' => 30,
'icon' => 'github.png',
'legacy_uri' => 'otpauth://totp/Github:@john?secret=A2GRFTVVRBGY7UIW',
]);
TwoFAccount::create([
],
[
'otp_type' => 'totp',
'service' => 'Google',
'account' => 'john.doe@gmail.com',
@ -136,6 +139,7 @@ public function run()
'period' => 30,
'icon' => 'google.png',
'legacy_uri' => 'otpauth://totp/Google:john.doe@gmail.com?secret=A5GRFTVVRBGY7UIW',
]
]);
}
}