Skip to content

Commit

Permalink
Update the seeders so that they set dynamic passwords by default
Browse files Browse the repository at this point in the history
  • Loading branch information
alextselegidis committed Mar 1, 2023
1 parent 963413e commit 2731d2f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions application/controllers/Console.php
Expand Up @@ -55,9 +55,9 @@ public function install()
{
$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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/Installation.php
Expand Up @@ -113,7 +113,7 @@ public function perform()
],
'settings' => [
'username' => 'janedoe',
'password' => 'janedoe',
'password' => random_string(),
'working_plan' => setting('company_working_plan'),
'notifications' => TRUE,
'google_sync' => FALSE,
Expand Down
17 changes: 14 additions & 3 deletions application/libraries/Instance.php
Expand Up @@ -84,31 +84,38 @@ public function migrate(string $type = '')

/**
* Seed the database with test data.
*
* @return string Return's the administrator user password.
*/
public function seed()
public function seed(): string
{
// Settings

setting([
'company_name' => 'Company Name',
'company_email' => 'info@example.org',
'company_link' => 'https://example.org',
]);

$password = random_string();

// Admin

$this->CI->admins_model->save([
'first_name' => 'John',
'last_name' => 'Doe',
'email' => 'john@example.org',
'phone_number' => '+10000000000',
'settings' => [
'username' => 'administrator',
'password' => 'administrator',
'password' => $password,
'notifications' => TRUE,
'calendar_view' => CALENDAR_VIEW_DEFAULT
],
]);

// Service

$service_id = $this->CI->services_model->save([
'name' => 'Service',
'duration' => '30',
Expand All @@ -119,6 +126,7 @@ public function seed()
]);

// Provider

$this->CI->providers_model->save([
'first_name' => 'Jane',
'last_name' => 'Doe',
Expand All @@ -129,7 +137,7 @@ public function seed()
],
'settings' => [
'username' => 'janedoe',
'password' => 'janedoe',
'password' => random_string(),
'working_plan' => setting('company_working_plan'),
'notifications' => TRUE,
'google_sync' => FALSE,
Expand All @@ -140,12 +148,15 @@ public function seed()
]);

// Customer

$this->CI->customers_model->save([
'first_name' => 'James',
'last_name' => 'Doe',
'email' => 'james@example.org',
'phone_number' => '+10000000000',
]);

return $password;
}

/**
Expand Down

0 comments on commit 2731d2f

Please sign in to comment.