E-Mail-Verifizierung (Entscheidung 15.06.): - User implementiert MustVerifyEmail; Registrierung legt inaktives, rollenloses Konto an und leitet auf die Danke-/Notice-Seite; Registered-Event versendet die Verifizierungsmail. Bestätigter Link aktiviert das Konto + vergibt customer-Rolle (ActivateUserAfterVerification). Backfill-Migration setzt email_verified_at für alle Bestands-User (sonst würde die verified-Middleware ~59k aktive Legacy-User aussperren). Seeder-User verifiziert. Auth-Flow-Korrekturen: - Magic-Link-Consume: rollensicherer Redirect ohne intended() (Customer landete sonst per stale intended=/dashboard im 403-Admin-Bereich). - Guest-Redirect (bootstrap/app.php) rollen-/verifizierungsbewusst statt fix /dashboard – schließt die 403-Sackgasse auf /login und /register. - Logout auf der Notice-Seite via echtes POST-Formular statt Livewire-Action (behebt 419 beim Session-Invalidate). - Magic-Link-Anforderung über eigenes Modal mit separater E-Mail-Eingabe. - Unverifizierte Login-Versuche landen auf der Notice-Seite. Sicherheitsfix Legacy-Rollen: - UserImporter mappte Alt-Gruppe 2 (Self-Publisher) auf editor (= Admin-Zugriff). Mapping auf customer korrigiert; Daten-Migration stuft die 65.950 fälschlichen Legacy-Editoren auf customer herab. Echte admin/api-only bleiben unberührt. Tests: Registration, EmailVerification, Authentication (Guest-Redirect), MagicLinkLogin (Modal/Redirect/Regression), Legacy-Import (Gruppen-Mapping). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Enums\Portal;
|
|
use App\Enums\RegistrationType;
|
|
use App\Models\User;
|
|
use App\Services\Auth\UserRolePermissionSyncService;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Seed the application's database.
|
|
*/
|
|
public function run(UserRolePermissionSyncService $rolePermissionSync): void
|
|
{
|
|
$this->call([
|
|
RolesAndPermissionsSeeder::class,
|
|
AdminPresetSeeder::class,
|
|
PaymentOptionSeeder::class,
|
|
// CategorySeeder::class,
|
|
]);
|
|
|
|
$adminUser = User::firstOrCreate([
|
|
'email' => 'admin@pressekonto.test',
|
|
], [
|
|
'name' => 'Portal Admin',
|
|
'password' => Hash::make('password'),
|
|
'portal' => Portal::Both->value,
|
|
'registration_type' => RegistrationType::ExistingLegacy->value,
|
|
'language' => 'de',
|
|
'is_active' => true,
|
|
'email_verified_at' => now(),
|
|
]);
|
|
|
|
$rolePermissionSync->assignRoleAndSyncPermissions($adminUser, 'admin');
|
|
|
|
$testUser = User::firstOrCreate([
|
|
'email' => 'test@example.com',
|
|
], [
|
|
'name' => 'Test User',
|
|
'password' => Hash::make('password'),
|
|
'portal' => Portal::Both->value,
|
|
'registration_type' => RegistrationType::ExistingLegacy->value,
|
|
'language' => 'de',
|
|
'is_active' => true,
|
|
'email_verified_at' => now(),
|
|
]);
|
|
|
|
$rolePermissionSync->assignRoleAndSyncPermissions($testUser, 'customer');
|
|
}
|
|
}
|