diff --git a/framework/core/src/Install/Console/DataFromUser.php b/framework/core/src/Install/Console/DataFromUser.php index 05af4c9be..98ebc09fc 100644 --- a/framework/core/src/Install/Console/DataFromUser.php +++ b/framework/core/src/Install/Console/DataFromUser.php @@ -37,12 +37,13 @@ class DataFromUser implements ProvidesData public function getDatabaseConfiguration() { return [ - 'driver' => 'mysql', - 'host' => $this->ask('Database host:'), - 'database' => $this->ask('Database name:'), - 'username' => $this->ask('Database user:'), - 'password' => $this->secret('Database password:'), - 'prefix' => $this->ask('Prefix:'), + 'driver' => 'mysql', + 'host' => $this->ask('Database host:'), + 'database' => $this->ask('Database name:'), + 'username' => $this->ask('Database user:'), + 'password' => $this->secret('Database password:'), + 'password_confirmation' => $this->secret('Database password (confirmation):'), + 'prefix' => $this->ask('Prefix:'), ]; } @@ -54,9 +55,10 @@ class DataFromUser implements ProvidesData public function getAdminUser() { return [ - 'username' => $this->ask('Admin username:'), - 'password' => $this->secret('Admin password:'), - 'email' => $this->ask('Admin email address:'), + 'username' => $this->ask('Admin username:'), + 'password' => $this->secret('Admin password:'), + 'password_confirmation' => $this->secret('Admin password (confirmation):'), + 'email' => $this->ask('Admin email address:'), ]; } diff --git a/framework/core/src/Install/Console/DefaultData.php b/framework/core/src/Install/Console/DefaultData.php index a0f4dc82b..4b60ceb54 100644 --- a/framework/core/src/Install/Console/DefaultData.php +++ b/framework/core/src/Install/Console/DefaultData.php @@ -13,12 +13,13 @@ namespace Flarum\Install\Console; class DefaultData implements ProvidesData { protected $databaseConfiguration = [ - 'driver' => 'mysql', - 'host' => 'localhost', - 'database' => 'flarum', - 'username' => 'root', - 'password' => 'root', - 'prefix' => '', + 'driver' => 'mysql', + 'host' => 'localhost', + 'database' => 'flarum', + 'username' => 'root', + 'password' => 'root', + 'password_confirmation' => 'root', + 'prefix' => '', ]; protected $baseUrl = 'http://flarum.dev'; @@ -26,6 +27,7 @@ class DefaultData implements ProvidesData protected $adminUser = [ 'username' => 'admin', 'password' => 'admin', + 'password_confirmation' => 'admin', 'email' => 'admin@example.com', ]; diff --git a/framework/core/src/Install/Console/InstallCommand.php b/framework/core/src/Install/Console/InstallCommand.php index ecb79b267..d8685ec5f 100644 --- a/framework/core/src/Install/Console/InstallCommand.php +++ b/framework/core/src/Install/Console/InstallCommand.php @@ -128,6 +128,10 @@ class InstallCommand extends Command { $dbConfig = $this->dataSource->getDatabaseConfiguration(); + if ($dbConfig['password'] !== $dbConfig['password_confirmation']) { + throw new Exception('The password did not match it\'s confirmation.'); + } + $config = [ 'debug' => true, 'database' => [ @@ -247,6 +251,10 @@ class InstallCommand extends Command { $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']); User::unguard();