Skip to content

Commit

Permalink
Add user on cachet install command
Browse files Browse the repository at this point in the history
  • Loading branch information
joecohens committed Jan 2, 2017
1 parent 0b7c787 commit 0f3a66f
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions app/Console/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace CachetHQ\Cachet\Console\Commands;

use CachetHQ\Cachet\Models\User;
use Dotenv\Dotenv;
use Dotenv\Exception\InvalidPathException;
use Illuminate\Console\Command;
Expand Down Expand Up @@ -55,6 +56,7 @@ public function fire()
$this->configureDrivers();
$this->configureMail();
$this->configureCachet();
$this->configureUser();

$this->info('Cachet is installed ⚡');
}
Expand Down Expand Up @@ -109,9 +111,9 @@ protected function configureDatabase(array $default = [])
], $default);

$config['DB_DRIVER'] = $this->choice('Which database driver do you want to use?', [
'mysql' => 'MySQL',
'postgresql' => 'PostgreSQL',
'sqlite' => 'SQLite',
'mysql' => 'MySQL',
'pgsql' => 'PostgreSQL',
'sqlite' => 'SQLite',
], $config['DB_DRIVER']);

if ($config['DB_DRIVER'] === 'sqlite') {
Expand Down Expand Up @@ -279,9 +281,11 @@ protected function configureMail(array $config = [])
/**
* Configure Cachet.
*
* @param array $config
*
* @return void
*/
protected function configureCachet()
protected function configureCachet(array $config = [])
{
if ($this->confirm('Do you wish to use Cachet Beacon?')) {
$config['CACHET_BEACON'] = 'true';
Expand All @@ -297,6 +301,27 @@ protected function configureCachet()
}
}

/**
* Configure the fisrt user.
*
* @return void
*/
protected function configureUser()
{
if (!$this->confirm('Do you want to create an admin user?')) {
return;
}

$user = [
'username' => $this->ask('Please enter your username'),
'email' => $this->ask('Please enter your email'),
'password' => $this->secret('Please enter your password'),
'level' => User::LEVEL_ADMIN,
];

User::create($user);
}

/**
* Configure the redis connection.
*
Expand Down

0 comments on commit 0f3a66f

Please sign in to comment.