mirror of
https://github.com/anna-sara/vbytes_lan.git
synced 2025-12-23 21:17:12 +01:00
Added column to user table for email auth
This commit is contained in:
parent
b74def256c
commit
19c995ad66
3 changed files with 53 additions and 3 deletions
|
|
@ -7,9 +7,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Filament\Models\Contracts\FilamentUser;
|
use Filament\Models\Contracts\FilamentUser;
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Filament\Auth\MultiFactor\Email\Contracts\HasEmailAuthentication;
|
||||||
use Filament\Panel;
|
use Filament\Panel;
|
||||||
|
|
||||||
class User extends Authenticatable implements FilamentUser
|
class User extends Authenticatable implements FilamentUser, HasEmailAuthentication, MustVerifyEmail
|
||||||
{
|
{
|
||||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||||
use HasFactory, Notifiable;
|
use HasFactory, Notifiable;
|
||||||
|
|
@ -23,6 +25,7 @@ class User extends Authenticatable implements FilamentUser
|
||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
'password',
|
'password',
|
||||||
|
'has_email_authentication'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -45,6 +48,7 @@ class User extends Authenticatable implements FilamentUser
|
||||||
return [
|
return [
|
||||||
'email_verified_at' => 'datetime',
|
'email_verified_at' => 'datetime',
|
||||||
'password' => 'hashed',
|
'password' => 'hashed',
|
||||||
|
'has_email_authentication' => 'boolean',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,4 +56,19 @@ class User extends Authenticatable implements FilamentUser
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasEmailAuthentication(): bool
|
||||||
|
{
|
||||||
|
// This method should return true if the user has enabled email authentication.
|
||||||
|
|
||||||
|
return $this->has_email_authentication;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggleEmailAuthentication(bool $condition): void
|
||||||
|
{
|
||||||
|
// This method should save whether or not the user has enabled email authentication.
|
||||||
|
|
||||||
|
$this->has_email_authentication = $condition;
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||||
use Illuminate\Session\Middleware\StartSession;
|
use Illuminate\Session\Middleware\StartSession;
|
||||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||||
|
use Filament\Auth\MultiFactor\Email\EmailAuthentication;
|
||||||
|
|
||||||
class AdminPanelProvider extends PanelProvider
|
class AdminPanelProvider extends PanelProvider
|
||||||
{
|
{
|
||||||
|
|
@ -28,11 +29,13 @@ class AdminPanelProvider extends PanelProvider
|
||||||
->id('admin')
|
->id('admin')
|
||||||
->path('')
|
->path('')
|
||||||
->login()
|
->login()
|
||||||
->registration()
|
->profile()
|
||||||
|
->multiFactorAuthentication([
|
||||||
|
EmailAuthentication::make(),
|
||||||
|
])
|
||||||
->passwordReset()
|
->passwordReset()
|
||||||
->emailVerification()
|
->emailVerification()
|
||||||
->emailChangeVerification()
|
->emailChangeVerification()
|
||||||
->profile()
|
|
||||||
->databaseNotifications()
|
->databaseNotifications()
|
||||||
->colors([
|
->colors([
|
||||||
'primary' => Color::Amber,
|
'primary' => Color::Amber,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->boolean('has_email_authentication')->default(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('has_email_authentication');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue