diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-10-02 23:10:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-02 23:10:51 +0200 |
commit | 126a82449090ccdb4fc050be4bf645e43de06100 (patch) | |
tree | 165f8a09649081a551328e9481075ad5a00244e0 | |
parent | 6b730b4c478bc4f55a89fd7d6a7c2715e2e5b829 (diff) | |
parent | a4eb3ee508804bc1c7c489ea252a9841139e38fb (diff) | |
download | nextcloud-server-126a82449090ccdb4fc050be4bf645e43de06100.tar.gz nextcloud-server-126a82449090ccdb4fc050be4bf645e43de06100.zip |
Merge pull request #11204 from nextcloud/feature/11153/add-adminemail-cli
Add --admin-email to cli installer
-rw-r--r-- | core/Command/Maintenance/Install.php | 7 | ||||
-rw-r--r-- | lib/private/Setup.php | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php index 262def99c5f..39692e036ba 100644 --- a/core/Command/Maintenance/Install.php +++ b/core/Command/Maintenance/Install.php @@ -67,6 +67,7 @@ class Install extends Command { ->addOption('database-table-space', null, InputOption::VALUE_OPTIONAL, 'Table space of the database (oci only)', null) ->addOption('admin-user', null, InputOption::VALUE_REQUIRED, 'User name of the admin account', 'admin') ->addOption('admin-pass', null, InputOption::VALUE_REQUIRED, 'Password of the admin account') + ->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'E-Mail of the admin account') ->addOption('data-dir', null, InputOption::VALUE_REQUIRED, 'Path to data directory', \OC::$SERVERROOT."/data"); } @@ -141,6 +142,7 @@ class Install extends Command { } $adminLogin = $input->getOption('admin-user'); $adminPassword = $input->getOption('admin-pass'); + $adminEmail = $input->getOption('admin-email'); $dataDir = $input->getOption('data-dir'); if ($db !== 'sqlite') { @@ -169,6 +171,10 @@ class Install extends Command { $adminPassword = $helper->ask($input, $output, $question); } + if ($adminEmail !== null && !filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) { + throw new InvalidArgumentException('Invalid e-mail-address <' . $adminEmail . '> for <' . $adminLogin . '>.'); + } + $options = [ 'dbtype' => $db, 'dbuser' => $dbUser, @@ -179,6 +185,7 @@ class Install extends Command { 'dbtableprefix' => $dbTablePrefix, 'adminlogin' => $adminLogin, 'adminpass' => $adminPassword, + 'adminemail' => $adminEmail, 'directory' => $dataDir ]; if ($db === 'oci') { diff --git a/lib/private/Setup.php b/lib/private/Setup.php index d5ccde6bba3..e9719705fcd 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -52,6 +52,7 @@ use OC\Preview\BackgroundCleanupJob; use OCP\Defaults; use OCP\IL10N; use OCP\ILogger; +use OCP\IUser; use OCP\Security\ISecureRandom; class Setup { @@ -412,6 +413,11 @@ class Setup { $userSession->setTokenProvider($defaultTokenProvider); $userSession->login($username, $password); $userSession->createSessionToken($request, $userSession->getUser()->getUID(), $username, $password); + + // Set email for admin + if (!empty($options['adminemail'])) { + $config->setUserValue($user->getUID(), 'settings', 'email', $options['adminemail']); + } } return $error; |