mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
feat: use default admin credentials during setup
This commit is contained in:
parent
7dad6aebf0
commit
4432ad6c21
4 changed files with 17 additions and 45 deletions
|
@ -17,13 +17,6 @@ DB_PASSWORD=SoSecureMuchWow
|
||||||
# A random 32-char string. You can leave this empty if use php artisan koel:init.
|
# A random 32-char string. You can leave this empty if use php artisan koel:init.
|
||||||
APP_KEY=
|
APP_KEY=
|
||||||
|
|
||||||
# Credentials and other info to be used when Koel is installed in non-interactive mode
|
|
||||||
# (php artisan koel:init --no-interaction)
|
|
||||||
# By default (interactive mode), Koel will still prompt for these information during installation,
|
|
||||||
# but provide the values here as the defaults (except ADMIN_PASSWORD, for security reason).
|
|
||||||
ADMIN_NAME="Koel Admin"
|
|
||||||
ADMIN_EMAIL=admin@koel.com
|
|
||||||
ADMIN_PASSWORD=SoSecureMuchWow
|
|
||||||
# The ABSOLUTE path to your media. This value can always be changed later via the web interface.
|
# The ABSOLUTE path to your media. This value can always be changed later via the web interface.
|
||||||
MEDIA_PATH=
|
MEDIA_PATH=
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,10 @@ class InitCommand extends Command
|
||||||
{
|
{
|
||||||
use AskForPassword;
|
use AskForPassword;
|
||||||
|
|
||||||
|
private const DEFAULT_ADMIN_NAME = 'Koel';
|
||||||
|
private const DEFAULT_ADMIN_EMAIL = 'admin@koel.dev';
|
||||||
|
private const DEFAULT_ADMIN_PASSWORD = 'KoelIsCool';
|
||||||
|
|
||||||
protected $signature = 'koel:init {--no-assets}';
|
protected $signature = 'koel:init {--no-assets}';
|
||||||
protected $description = 'Install or upgrade Koel';
|
protected $description = 'Install or upgrade Koel';
|
||||||
|
|
||||||
|
@ -28,6 +32,7 @@ class InitCommand extends Command
|
||||||
private $hash;
|
private $hash;
|
||||||
private $db;
|
private $db;
|
||||||
private $settingRepository;
|
private $settingRepository;
|
||||||
|
private $adminSeeded = false;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
MediaCacheService $mediaCacheService,
|
MediaCacheService $mediaCacheService,
|
||||||
|
@ -74,6 +79,12 @@ class InitCommand extends Command
|
||||||
|
|
||||||
$this->comment(PHP_EOL . '🎆 Success! Koel can now be run from localhost with `php artisan serve`.');
|
$this->comment(PHP_EOL . '🎆 Success! Koel can now be run from localhost with `php artisan serve`.');
|
||||||
|
|
||||||
|
if ($this->adminSeeded) {
|
||||||
|
$this->comment(
|
||||||
|
sprintf('Log in with email %s and password %s', self::DEFAULT_ADMIN_EMAIL, self::DEFAULT_ADMIN_PASSWORD)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (Setting::get('media_path')) {
|
if (Setting::get('media_path')) {
|
||||||
$this->comment('You can also scan for media with `php artisan koel:sync`.');
|
$this->comment('You can also scan for media with `php artisan koel:sync`.');
|
||||||
}
|
}
|
||||||
|
@ -151,16 +162,16 @@ class InitCommand extends Command
|
||||||
|
|
||||||
private function setUpAdminAccount(): void
|
private function setUpAdminAccount(): void
|
||||||
{
|
{
|
||||||
$this->info("Let's create the admin account.");
|
$this->info("Creating default admin account");
|
||||||
|
|
||||||
[$name, $email, $password] = $this->gatherAdminAccountCredentials();
|
|
||||||
|
|
||||||
User::create([
|
User::create([
|
||||||
'name' => $name,
|
'name' => self::DEFAULT_ADMIN_NAME,
|
||||||
'email' => $email,
|
'email' => self::DEFAULT_ADMIN_EMAIL,
|
||||||
'password' => $this->hash->make($password),
|
'password' => $this->hash->make(self::DEFAULT_ADMIN_PASSWORD),
|
||||||
'is_admin' => true,
|
'is_admin' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->adminSeeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function maybeSetMediaPath(): void
|
private function maybeSetMediaPath(): void
|
||||||
|
@ -270,20 +281,6 @@ class InitCommand extends Command
|
||||||
$runOkOrThrow('yarn build --colors');
|
$runOkOrThrow('yarn build --colors');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return array<string> */
|
|
||||||
private function gatherAdminAccountCredentials(): array
|
|
||||||
{
|
|
||||||
if ($this->inNoInteractionMode()) {
|
|
||||||
return [config('koel.admin.name'), config('koel.admin.email'), config('koel.admin.password')];
|
|
||||||
}
|
|
||||||
|
|
||||||
$name = $this->ask('Your name', config('koel.admin.name'));
|
|
||||||
$email = $this->ask('Your email address', config('koel.admin.email'));
|
|
||||||
$password = $this->askForPassword();
|
|
||||||
|
|
||||||
return [$name, $email, $password];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function isValidMediaPath(string $path): bool
|
private function isValidMediaPath(string $path): bool
|
||||||
{
|
{
|
||||||
return is_dir($path) && is_readable($path);
|
return is_dir($path) && is_readable($path);
|
||||||
|
|
|
@ -1,21 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Admin Credentials
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| When running `php artisan koel:init` the admin is set using the .env
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'admin' => [
|
|
||||||
'name' => env('ADMIN_NAME'),
|
|
||||||
'email' => env('ADMIN_EMAIL'),
|
|
||||||
'password' => env('ADMIN_PASSWORD'),
|
|
||||||
],
|
|
||||||
|
|
||||||
'media_path' => env('MEDIA_PATH'),
|
'media_path' => env('MEDIA_PATH'),
|
||||||
|
|
||||||
// The *relative* path to the directory to store album covers and thumbnails, *with* a trailing slash.
|
// The *relative* path to the directory to store album covers and thumbnails, *with* a trailing slash.
|
||||||
|
|
|
@ -42,9 +42,6 @@
|
||||||
<env name="LASTFM_API_KEY" value="foo"/>
|
<env name="LASTFM_API_KEY" value="foo"/>
|
||||||
<env name="LASTFM_API_SECRET" value="bar"/>
|
<env name="LASTFM_API_SECRET" value="bar"/>
|
||||||
<env name="YOUTUBE_API_KEY" value="foo"/>
|
<env name="YOUTUBE_API_KEY" value="foo"/>
|
||||||
<env name="ADMIN_EMAIL" value="koel@example.com"/>
|
|
||||||
<env name="ADMIN_NAME" value="Koel"/>
|
|
||||||
<env name="ADMIN_PASSWORD" value="SoSecureK0el"/>
|
|
||||||
<env name="BROADCAST_DRIVER" value="log"/>
|
<env name="BROADCAST_DRIVER" value="log"/>
|
||||||
<env name="CACHE_MEDIA" value="true"/>
|
<env name="CACHE_MEDIA" value="true"/>
|
||||||
<ini name="memory_limit" value="512M"/>
|
<ini name="memory_limit" value="512M"/>
|
||||||
|
|
Loading…
Reference in a new issue