Update the seeders so that they set dynamic passwords by default

This commit is contained in:
Alex Tselegidis 2023-03-01 09:00:24 +01:00
parent 963413eb88
commit 2731d2f17c
3 changed files with 17 additions and 6 deletions

View file

@ -55,9 +55,9 @@ class Console extends EA_Controller {
{ {
$this->instance->migrate('fresh'); $this->instance->migrate('fresh');
$this->instance->seed(); $password = $this->instance->seed();
response(PHP_EOL . '⇾ Installation completed, login with "administrator" / "administrator".' . PHP_EOL . PHP_EOL); response(PHP_EOL . '⇾ Installation completed, login with "administrator" / "' . $password . '".' . PHP_EOL . PHP_EOL);
} }
/** /**

View file

@ -113,7 +113,7 @@ class Installation extends EA_Controller {
], ],
'settings' => [ 'settings' => [
'username' => 'janedoe', 'username' => 'janedoe',
'password' => 'janedoe', 'password' => random_string(),
'working_plan' => setting('company_working_plan'), 'working_plan' => setting('company_working_plan'),
'notifications' => TRUE, 'notifications' => TRUE,
'google_sync' => FALSE, 'google_sync' => FALSE,

View file

@ -84,17 +84,23 @@ class Instance {
/** /**
* Seed the database with test data. * Seed the database with test data.
*
* @return string Return's the administrator user password.
*/ */
public function seed() public function seed(): string
{ {
// Settings // Settings
setting([ setting([
'company_name' => 'Company Name', 'company_name' => 'Company Name',
'company_email' => 'info@example.org', 'company_email' => 'info@example.org',
'company_link' => 'https://example.org', 'company_link' => 'https://example.org',
]); ]);
$password = random_string();
// Admin // Admin
$this->CI->admins_model->save([ $this->CI->admins_model->save([
'first_name' => 'John', 'first_name' => 'John',
'last_name' => 'Doe', 'last_name' => 'Doe',
@ -102,13 +108,14 @@ class Instance {
'phone_number' => '+10000000000', 'phone_number' => '+10000000000',
'settings' => [ 'settings' => [
'username' => 'administrator', 'username' => 'administrator',
'password' => 'administrator', 'password' => $password,
'notifications' => TRUE, 'notifications' => TRUE,
'calendar_view' => CALENDAR_VIEW_DEFAULT 'calendar_view' => CALENDAR_VIEW_DEFAULT
], ],
]); ]);
// Service // Service
$service_id = $this->CI->services_model->save([ $service_id = $this->CI->services_model->save([
'name' => 'Service', 'name' => 'Service',
'duration' => '30', 'duration' => '30',
@ -119,6 +126,7 @@ class Instance {
]); ]);
// Provider // Provider
$this->CI->providers_model->save([ $this->CI->providers_model->save([
'first_name' => 'Jane', 'first_name' => 'Jane',
'last_name' => 'Doe', 'last_name' => 'Doe',
@ -129,7 +137,7 @@ class Instance {
], ],
'settings' => [ 'settings' => [
'username' => 'janedoe', 'username' => 'janedoe',
'password' => 'janedoe', 'password' => random_string(),
'working_plan' => setting('company_working_plan'), 'working_plan' => setting('company_working_plan'),
'notifications' => TRUE, 'notifications' => TRUE,
'google_sync' => FALSE, 'google_sync' => FALSE,
@ -140,12 +148,15 @@ class Instance {
]); ]);
// Customer // Customer
$this->CI->customers_model->save([ $this->CI->customers_model->save([
'first_name' => 'James', 'first_name' => 'James',
'last_name' => 'Doe', 'last_name' => 'Doe',
'email' => 'james@example.org', 'email' => 'james@example.org',
'phone_number' => '+10000000000', 'phone_number' => '+10000000000',
]); ]);
return $password;
} }
/** /**