mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
During the regular october install using october:install, the user-defined password is overwritten with the random generated string password. Instead, now it uses random password only if the user-defined password defaults to *admin* and if a user did set a custom password, that is used instead.
33 lines
996 B
PHP
33 lines
996 B
PHP
<?php namespace Backend\Database\Seeds;
|
|
|
|
use Str;
|
|
use Seeder;
|
|
use Eloquent;
|
|
use Backend\Database\Seeds\SeedSetupAdmin;
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function run()
|
|
{
|
|
$shouldRandomizePassword = SeedSetupAdmin::$password === 'admin';
|
|
$adminPassword = $shouldRandomizePassword ? Str::random(22) : SeedSetupAdmin::$password;
|
|
|
|
Eloquent::unguarded(function () use ($adminPassword) {
|
|
// Generate a random password for the seeded admin account
|
|
$adminSeeder = new \Backend\Database\Seeds\SeedSetupAdmin;
|
|
$adminSeeder->setDefaults([
|
|
'password' => $adminPassword
|
|
]);
|
|
$this->call($adminSeeder);
|
|
});
|
|
|
|
return $shouldRandomizePassword ? 'The following password has been automatically generated for the "admin" account: '
|
|
. "<fg=yellow;options=bold>${adminPassword}</>" : '';
|
|
}
|
|
}
|