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