feat: complete user authentication, admin guard, customer account dashboard and branded HTML emails
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AdminCredentialsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:admin-credentials {--reset : Generate a new random password for the admin}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Toon of herstel de beheerder (admin) inloggegevens';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$email = 'info@jouwdriedee.nl';
|
||||
$admin = User::where('email', $email)->first();
|
||||
|
||||
if (! $admin || $this->option('reset')) {
|
||||
$newPassword = Str::password(16);
|
||||
|
||||
$admin = User::updateOrCreate(
|
||||
['email' => $email],
|
||||
[
|
||||
'name' => 'Jouwdriedee Beheer',
|
||||
'password' => Hash::make($newPassword),
|
||||
'is_admin' => true,
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->info('Admin gebruiker succesvol aangemaakt/bijgewerkt met een nieuw wachtwoord:');
|
||||
$this->table(['Veld', 'Waarde'], [
|
||||
['E-mailadres', $email],
|
||||
['Nieuw Wachtwoord', $newPassword],
|
||||
['Admin Status', 'Ja (is_admin = true)'],
|
||||
]);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$this->info("Admin gebruiker '{$email}' bestaat reeds in het systeem.");
|
||||
$this->table(['Veld', 'Waarde'], [
|
||||
['E-mailadres', $email],
|
||||
['Naam', $admin->name],
|
||||
['Admin Status', $admin->isAdmin() ? 'Ja' : 'Nee'],
|
||||
['Aangemaakt op', $admin->created_at->format('d-m-Y H:i')],
|
||||
]);
|
||||
|
||||
$this->line("Tip: Draai 'php artisan app:admin-credentials --reset' om een nieuw random wachtwoord te genereren.");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user