feat: implement admin user management interface and registration command
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateAdmin extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'admin:create';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create or reset admin user admin@citrus.com with a random password';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$email = 'admin@citrus.com';
|
||||
$password = Str::random(12);
|
||||
|
||||
$user = User::where('email', $email)->first();
|
||||
|
||||
if ($user) {
|
||||
$user->password = Hash::make($password);
|
||||
$user->level = 'Admin';
|
||||
$user->save();
|
||||
$status = 'updated';
|
||||
} else {
|
||||
$user = new User();
|
||||
$user->name = 'Admin';
|
||||
$user->email = $email;
|
||||
$user->password = Hash::make($password);
|
||||
$user->level = 'Admin';
|
||||
$user->save();
|
||||
$status = 'created';
|
||||
}
|
||||
|
||||
$this->info("Admin user has been {$status}.");
|
||||
$this->line("--------------------------------");
|
||||
$this->info("Email: {$email}");
|
||||
$this->info("Password: {$password}");
|
||||
$this->line("--------------------------------");
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/exceljs/4.1.1/exceljs.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.2/FileSaver.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.0.0/jspdf.umd.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/devextreme-dist/23.1.5/css/<?php echo setting("DevExpress_Theme", false,"dx.light.compact") ?>">
|
||||
<link rel="stylesheet" href="https://cdn3.devexpress.com/jslib/23.1.5/css/<?php echo setting("DevExpress_Theme", false,"dx.light.compact") ?>.css">
|
||||
<!-- Quill CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.quilljs.com/1.3.7/quill.snow.css">
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ class User extends Authenticatable
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'level',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user