2020-03-19 22:25:04 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
2022-07-07 16:39:57 +02:00
|
|
|
use App\Console\Commands\Utils\ResetTrait;
|
2020-03-19 22:25:04 +01:00
|
|
|
|
|
|
|
class ResetDemo extends Command
|
|
|
|
{
|
2022-07-07 16:39:57 +02:00
|
|
|
use ResetTrait;
|
|
|
|
|
2020-03-19 22:25:04 +01:00
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2020-03-20 21:46:06 +01:00
|
|
|
protected $signature = '2fauth:reset-demo {--no-confirm}';
|
2020-03-19 22:25:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Reset 2FAuth with a fresh demo content';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2021-10-01 13:34:28 +02:00
|
|
|
if( !config('2fauth.config.isDemoApp') ) {
|
2020-03-19 22:25:04 +01:00
|
|
|
$this->comment('2fauth:reset-demo can only run when isDemoApp option is On');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-03-20 21:46:06 +01:00
|
|
|
if( $this->option('no-confirm') ) {
|
|
|
|
$demo = 'demo';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->line('This will reset the app in order to run a clean and fresh demo.');
|
|
|
|
$demo = $this->ask('To prevent any mistake please type the word "demo" to go on');
|
|
|
|
}
|
2020-03-19 22:25:04 +01:00
|
|
|
|
|
|
|
if ($demo === 'demo') {
|
2022-07-07 16:39:57 +02:00
|
|
|
$this->resetIcons();
|
|
|
|
$this->resetDB('DemoSeeder');
|
2020-03-20 23:15:36 +01:00
|
|
|
$this->info('Demo app refreshed');
|
2020-03-19 22:25:04 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->comment('Bad confirmation word, nothing appened');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|