1
0
mirror of https://github.com/flarum/core.git synced 2025-07-25 10:41:24 +02:00

Require password confirmation in console installer

Refs #405.
This commit is contained in:
Franz Liedke
2015-09-04 11:57:11 +02:00
parent 47881bc744
commit 56efeb3a1e
3 changed files with 27 additions and 15 deletions

View File

@@ -37,12 +37,13 @@ class DataFromUser implements ProvidesData
public function getDatabaseConfiguration() public function getDatabaseConfiguration()
{ {
return [ return [
'driver' => 'mysql', 'driver' => 'mysql',
'host' => $this->ask('Database host:'), 'host' => $this->ask('Database host:'),
'database' => $this->ask('Database name:'), 'database' => $this->ask('Database name:'),
'username' => $this->ask('Database user:'), 'username' => $this->ask('Database user:'),
'password' => $this->secret('Database password:'), 'password' => $this->secret('Database password:'),
'prefix' => $this->ask('Prefix:'), 'password_confirmation' => $this->secret('Database password (confirmation):'),
'prefix' => $this->ask('Prefix:'),
]; ];
} }
@@ -54,9 +55,10 @@ class DataFromUser implements ProvidesData
public function getAdminUser() public function getAdminUser()
{ {
return [ return [
'username' => $this->ask('Admin username:'), 'username' => $this->ask('Admin username:'),
'password' => $this->secret('Admin password:'), 'password' => $this->secret('Admin password:'),
'email' => $this->ask('Admin email address:'), 'password_confirmation' => $this->secret('Admin password (confirmation):'),
'email' => $this->ask('Admin email address:'),
]; ];
} }

View File

@@ -13,12 +13,13 @@ namespace Flarum\Install\Console;
class DefaultData implements ProvidesData class DefaultData implements ProvidesData
{ {
protected $databaseConfiguration = [ protected $databaseConfiguration = [
'driver' => 'mysql', 'driver' => 'mysql',
'host' => 'localhost', 'host' => 'localhost',
'database' => 'flarum', 'database' => 'flarum',
'username' => 'root', 'username' => 'root',
'password' => 'root', 'password' => 'root',
'prefix' => '', 'password_confirmation' => 'root',
'prefix' => '',
]; ];
protected $baseUrl = 'http://flarum.dev'; protected $baseUrl = 'http://flarum.dev';
@@ -26,6 +27,7 @@ class DefaultData implements ProvidesData
protected $adminUser = [ protected $adminUser = [
'username' => 'admin', 'username' => 'admin',
'password' => 'admin', 'password' => 'admin',
'password_confirmation' => 'admin',
'email' => 'admin@example.com', 'email' => 'admin@example.com',
]; ];

View File

@@ -128,6 +128,10 @@ class InstallCommand extends Command
{ {
$dbConfig = $this->dataSource->getDatabaseConfiguration(); $dbConfig = $this->dataSource->getDatabaseConfiguration();
if ($dbConfig['password'] !== $dbConfig['password_confirmation']) {
throw new Exception('The password did not match it\'s confirmation.');
}
$config = [ $config = [
'debug' => true, 'debug' => true,
'database' => [ 'database' => [
@@ -247,6 +251,10 @@ class InstallCommand extends Command
{ {
$admin = $this->dataSource->getAdminUser(); $admin = $this->dataSource->getAdminUser();
if ($admin['password'] !== $admin['password_confirmation']) {
throw new Exception('The password did not match it\'s confirmation.');
}
$this->info('Creating admin user '.$admin['username']); $this->info('Creating admin user '.$admin['username']);
User::unguard(); User::unguard();