Give the demo account a real password, not one written in the source
The demo customer is a genuine login on a panel that answers from the public internet. A default password in a seeder would sit on production for as long as the demo does, and "it is only the demo account" is how the first one gets taken. It now takes DEMO_PASSWORD if the operator sets one and otherwise mints a 24-character random password, printed once at seed time. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>feat/mailboxes
parent
435a202fdd
commit
4daf37a10b
|
|
@ -16,6 +16,7 @@ use App\Models\User;
|
|||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* One complete customer, written as real rows.
|
||||
|
|
@ -39,11 +40,22 @@ class DemoCustomerSeeder extends Seeder
|
|||
|
||||
public function run(): void
|
||||
{
|
||||
// The demo account is a real login on a panel that is reachable from the
|
||||
// public internet, so it never gets a password written in a source file.
|
||||
// DEMO_PASSWORD if the operator set one, otherwise a fresh random one
|
||||
// printed once — a weak default would sit on production forever, and
|
||||
// "it is only the demo" is how the first account gets taken.
|
||||
$password = (string) (env('DEMO_PASSWORD') ?: Str::password(24));
|
||||
|
||||
$user = User::firstOrCreate(
|
||||
['email' => self::EMAIL],
|
||||
['name' => 'Kanzlei Muster', 'password' => Hash::make(config('app.demo_password', 'Muster!2026'))],
|
||||
['name' => 'Kanzlei Muster', 'password' => Hash::make($password)],
|
||||
);
|
||||
|
||||
if ($user->wasRecentlyCreated) {
|
||||
$this->command?->warn('Demo password (shown once): '.$password);
|
||||
}
|
||||
|
||||
$customer = Customer::firstOrCreate(
|
||||
['user_id' => $user->id],
|
||||
['name' => 'Kanzlei Muster', 'email' => self::EMAIL, 'contact_name' => 'Dr. M. Muster', 'status' => 'active'],
|
||||
|
|
|
|||
Loading…
Reference in New Issue