Skip to content

Commit

Permalink
Add default user account on setup (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaiss authored Dec 14, 2017
1 parent fb004fc commit c8c1dd5
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 11 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
UNRELEASED CHANGES:

*

RELEASED VERSIONS:

v1.4.1 - 2017-12-13
-------------------

* Add default user account on setup

v1.4.0 - 2017-12-13
-------------------

* Add ability to add a birthday (or any date) without knowing the year
* Add the artisan command (CLI) `php artisan setup:test` to setup the development environment
* Remove the table `important_dates` which was not used
* Change how resetting an account is achieved
* Add progress bar when generating fake data to populate the dev environment

RELEASED VERSIONS:

v1.3.0 - 2017-12-04
-------------------

Expand Down
50 changes: 44 additions & 6 deletions app/Console/Commands/SetupProduction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

namespace App\Console\Commands;

use DB;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;

class SetupProduction extends Command
{
use ConfirmableTrait;

/**
* The name and signature of the console command.
*
Expand Down Expand Up @@ -38,7 +36,7 @@ public function __construct()
*/
public function handle()
{
if (! $this->confirmToProceed()) {
if (! $this->confirm('You are about to setup and configure Monica. Do you wish to continue?')) {
return;
}

Expand All @@ -50,9 +48,49 @@ public function handle()
touch('.env');
}

$this->call('migrate', ['--force' => true]);
$this->callSilent('migrate', ['--force' => true]);
$this->info('✓ Performed migrations');

$this->call('db:seed', ['--class' => 'ActivityTypesTableSeeder', '--force' => true]);
$this->info('✓ Filled the Activity Types table');

$this->call('db:seed', ['--class' => 'CountriesSeederTable', '--force' => true]);
$this->call('storage:link');
$this->info('✓ Filled the Countries table');

$this->callSilent('storage:link');
$this->info('✓ Symlinked the storage folder for the avatars');

$email = $this->ask('Account creation: what should be your email address to login?');
$password = $this->secret('Please choose a password:');

// populate account table
$accountID = DB::table('accounts')->insertGetId([
'api_key' => str_random(30),
]);

// populate user table
$userId = DB::table('users')->insertGetId([
'account_id' => $accountID,
'first_name' => 'John',
'last_name' => 'Doe',
'email' => $email,
'password' => bcrypt($password),
'timezone' => config('app.timezone'),
'remember_token' => str_random(10),
]);

$this->line('');
$this->line('-----------------------------');
$this->line('|');
$this->line('| Welcome to Monica v'.config('monica.app_version'));
$this->line('|');
$this->line('-----------------------------');
$this->info('| You can now sign in to your account:');
$this->line('| username: '.$email);
$this->line('| password: <hidden>');
$this->line('| URL: '.config('app.url'));
$this->line('-----------------------------');

$this->info('Setup is done. Have fun.');
}
}
3 changes: 3 additions & 0 deletions app/Console/Commands/SetupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public function handle()
$this->call('db:seed', ['--class' => 'CountriesSeederTable']);
$this->info('✓ Filled the Countries table');

$this->callSilent('storage:link');
$this->info('✓ Symlinked the storage folder for the avatars');

if (! $this->option('skipSeed')) {
$this->call('db:seed', ['--class' => 'FakeContentTableSeeder']);
$this->info('');
Expand Down
2 changes: 1 addition & 1 deletion config/monica.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,5 @@
| bad things will happen.
|
*/
'app_version' => '1.3.0',
'app_version' => '1.4.1',
];
1 change: 0 additions & 1 deletion docs/contribute/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ Once the above softwares are installed (or if you've finished the installation o
1. `php artisan setup:test` to setup the database.
1. By default this command will also populate the database with fake data.
1. Use the `-- skipSeed` option to skip the process of adding fake data in your dev environment.
1. `php artisan storage:link` to symlink the avatars of the contacts.
1. Optional: `php artisan passport:install` to create the access tokens required for the API.

If you haven't skipped the seeding of fake data, two accounts are created by default:
Expand Down
1 change: 0 additions & 1 deletion docs/installation/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ to check for breaking changes.
1. Then, run the following command at the root of the project:

```
php artisan monica:update
git pull origin master
composer install --no-interaction --prefer-dist --optimize-autoloader
php artisan migrate --force
Expand Down

0 comments on commit c8c1dd5

Please sign in to comment.