mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat(monitoring): add pulse
- Added a new gate called `viewPulse` in the `AuthServiceProvider` class. - The gate allows only admin users to view the Pulse feature.
This commit is contained in:
51
app/Console/Commands/UserCreateCommand.php
Normal file
51
app/Console/Commands/UserCreateCommand.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserCreateCommand extends Command
|
||||
{
|
||||
protected $signature = 'user:create';
|
||||
|
||||
protected $description = 'Create a new user from CLI';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
if (config('app.env') === 'production') {
|
||||
if (!$this->confirm('You are in production mode. Are you sure you want to continue?')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Creating a new user...');
|
||||
|
||||
$name = $this->ask('Name');
|
||||
$email = $this->ask('Email');
|
||||
$password = $this->secret('Password');
|
||||
$password_confirmation = $this->secret('Confirm password');
|
||||
$admin = $this->confirm('Is this user an admin?');
|
||||
|
||||
$this->info('Name: ' . $name);
|
||||
$this->info('Email: ' . $email);
|
||||
$this->info('Password: ' . $password);
|
||||
$this->info('Password confirmation: ' . $password_confirmation);
|
||||
$this->info('Admin: ' . $admin);
|
||||
|
||||
if ($password !== $password_confirmation) {
|
||||
$this->error('Passwords do not match!');
|
||||
return;
|
||||
}
|
||||
|
||||
$user = User::create([
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'password' => bcrypt($password),
|
||||
'admin' => $admin,
|
||||
]);
|
||||
|
||||
$this->info('User with name ' . $user->name . 'created successfully.');
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ class User extends Authenticatable
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'admin',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,28 +2,19 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
// use Illuminate\Support\Facades\Gate;
|
||||
use App\Models\SummonerEmote;
|
||||
use App\Policies\SummonerEmotePolicy;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The model to policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
//
|
||||
SummonerEmote::class => SummonerEmotePolicy::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
Gate::define('viewPulse', function (User $user) {
|
||||
return $user->admin;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Home;
|
||||
namespace App\View\Components\home;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
Reference in New Issue
Block a user