Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add artisan command to create new account #4745

Merged
merged 13 commits into from Jan 31, 2021
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -7,7 +7,7 @@

### Enhancements:

*
* Add an artisan command to create an account

### Fixes:

Expand Down
53 changes: 53 additions & 0 deletions app/Console/Commands/CreateAccount.php
@@ -0,0 +1,53 @@
<?php

namespace App\Console\Commands;

use App\Models\Account\Account;
use Illuminate\Console\Command;

class CreateAccount extends Command
codemonkeysoftware marked this conversation as resolved.
Show resolved Hide resolved
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'account:create
{--email= : Login email for the account.}
{--password= : Password to set for the account.}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new account';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$email = $this->option('email');
if (empty($email)) {
$this->error('! You must specify an email');
}

$password = $this->option('password');
if (empty($password)) {
$this->error('! You must specify a password');
}

if (empty($email) || empty($password)) {
return;
}

Account::createDefault('John', 'Doe', $email, $password);
codemonkeysoftware marked this conversation as resolved.
Show resolved Hide resolved

$this->info('| You can now sign in to your account:');
$this->line('| username: '.$email);
$this->line('| password: <hidden>');
}
}
2 changes: 2 additions & 0 deletions app/Console/Kernel.php
Expand Up @@ -13,6 +13,7 @@
use App\Console\Commands\ImportVCards;
use App\Console\Commands\LangGenerate;
use App\Console\Commands\SetUserAdmin;
use App\Console\Commands\CreateAccount;
use App\Console\Commands\Deactivate2FA;
use App\Console\Commands\SendReminders;
use App\Console\Commands\SendTestEmail;
Expand Down Expand Up @@ -40,6 +41,7 @@ class Kernel extends ConsoleKernel
protected $commands = [
CalculateStatistics::class,
Clean::class,
CreateAccount::class,
Deactivate2FA::class,
ExportAll::class,
GetVersion::class,
Expand Down