diff --git a/app/Actions/Fortify/CreateNewUser.php b/app/Actions/Fortify/CreateNewUser.php index f39ca9a..19d75aa 100644 --- a/app/Actions/Fortify/CreateNewUser.php +++ b/app/Actions/Fortify/CreateNewUser.php @@ -6,6 +6,7 @@ use App\Models\User; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; +use Illuminate\Auth\Events\Registered; use Laravel\Fortify\Contracts\CreatesNewUsers; class CreateNewUser implements CreatesNewUsers @@ -40,5 +41,9 @@ class CreateNewUser implements CreatesNewUsers 'phone' => $input['phone'] ?? null, 'type' => 'user', // default ]); + + event(new Registered($user)); + + return $user; } } diff --git a/app/Mail/VerifyEmail.php b/app/Mail/VerifyEmail.php new file mode 100644 index 0000000..875c5b1 --- /dev/null +++ b/app/Mail/VerifyEmail.php @@ -0,0 +1,53 @@ + + */ + public function attachments(): array + { + return []; + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 0ff4782..eee18f3 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,15 +2,16 @@ namespace App\Models; -// use Illuminate\Contracts\Auth\MustVerifyEmail; +use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Laravel\Fortify\TwoFactorAuthenticatable; -class User extends Authenticatable +class User extends Authenticatable implements MustVerifyEmail { /** @use HasFactory<\Database\Factories\UserFactory> */ - use HasFactory, Notifiable; + use HasFactory, Notifiable, TwoFactorAuthenticatable; /** * The attributes that are mass assignable. diff --git a/app/Providers/FortifyServiceProvider.php b/app/Providers/FortifyServiceProvider.php index acbfbf3..e4d5baf 100644 --- a/app/Providers/FortifyServiceProvider.php +++ b/app/Providers/FortifyServiceProvider.php @@ -35,8 +35,6 @@ class FortifyServiceProvider extends ServiceProvider return view('auth.register'); }); - - Fortify::createUsersUsing(CreateNewUser::class); Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class); Fortify::updateUserPasswordsUsing(UpdateUserPassword::class); diff --git a/config/fortify.php b/config/fortify.php index 04a9d52..de0b96a 100644 --- a/config/fortify.php +++ b/config/fortify.php @@ -146,7 +146,7 @@ return [ 'features' => [ Features::registration(), Features::resetPasswords(), - // Features::emailVerification(), + Features::emailVerification(), Features::updateProfileInformation(), Features::updatePasswords(), Features::twoFactorAuthentication([ diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 05fb5d9..5ab624e 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -16,6 +16,7 @@ return new class extends Migration $table->string('name'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); + $table->string('email_verification_token')->nullable(); $table->string('password'); $table->rememberToken(); $table->timestamps(); diff --git a/resources/views/admin/home.blade.php b/resources/views/admin/home.blade.php index a738ed0..e6eeded 100644 --- a/resources/views/admin/home.blade.php +++ b/resources/views/admin/home.blade.php @@ -1 +1,5 @@ -This is Admin Home +@extends('admin.layouts.master') + +@section('content') + this is Admin panel +@endsection diff --git a/resources/views/admin/layouts/account-menu.blade.php b/resources/views/admin/layouts/account-menu.blade.php new file mode 100644 index 0000000..582d5ff --- /dev/null +++ b/resources/views/admin/layouts/account-menu.blade.php @@ -0,0 +1,35 @@ + diff --git a/resources/views/admin/layouts/head-tag.blade.php b/resources/views/admin/layouts/head-tag.blade.php new file mode 100644 index 0000000..b561107 --- /dev/null +++ b/resources/views/admin/layouts/head-tag.blade.php @@ -0,0 +1,8 @@ + + + + @yield('title', 'Admin Dashboard') + + + + diff --git a/resources/views/admin/layouts/js.blade.php b/resources/views/admin/layouts/js.blade.php new file mode 100644 index 0000000..d36656d --- /dev/null +++ b/resources/views/admin/layouts/js.blade.php @@ -0,0 +1,5 @@ + + + diff --git a/resources/views/admin/layouts/master.blade.php b/resources/views/admin/layouts/master.blade.php new file mode 100644 index 0000000..1f36f7d --- /dev/null +++ b/resources/views/admin/layouts/master.blade.php @@ -0,0 +1,41 @@ + + + +@include('admin.layouts.head-tag') + + + +@include('admin.layouts.mobile-menu') + +
+ + @include('admin.layouts.side-menu') + + +
+ +
+ + {{-- Todo: hear rote link on dashbord --}} + + + + @include('admin.layouts.account-menu') + +
+ +
+ + @yield('content', 'Welcome') + +
+
+ +
+ +@include('admin.layouts.js') + + + diff --git a/resources/views/admin/layouts/mobile-menu.blade.php b/resources/views/admin/layouts/mobile-menu.blade.php new file mode 100644 index 0000000..2eaf94c --- /dev/null +++ b/resources/views/admin/layouts/mobile-menu.blade.php @@ -0,0 +1,470 @@ +
+
+ + Midone Tailwind HTML Admin Template + + +
+ +
diff --git a/resources/views/admin/layouts/side-menu.blade.php b/resources/views/admin/layouts/side-menu.blade.php new file mode 100644 index 0000000..bec0eb3 --- /dev/null +++ b/resources/views/admin/layouts/side-menu.blade.php @@ -0,0 +1,479 @@ + diff --git a/resources/views/auth/verify-email.blade.php b/resources/views/auth/verify-email.blade.php new file mode 100644 index 0000000..9afea66 --- /dev/null +++ b/resources/views/auth/verify-email.blade.php @@ -0,0 +1,28 @@ + +
+
+
+
+
{{ __('Verify Your Email Address') }}
+ +
+ @if (session('status') == 'verification-link-sent') +
+ {{ __('A new verification link has been sent to your email address.') }} +
+ @endif + + {{ __('Before proceeding, please check your email for a verification link.') }} + {{ __('If you did not receive the email') }}, + +
+ @csrf + . +
+
+
+
+
+
diff --git a/resources/views/emails/verify-email.blade.php b/resources/views/emails/verify-email.blade.php new file mode 100644 index 0000000..fb8c447 --- /dev/null +++ b/resources/views/emails/verify-email.blade.php @@ -0,0 +1,11 @@ +@component('mail::message') + # Verify Email Address + + Click the button below to verify your email address. + + @component('mail::button', ['url' => $verificationUrl]) + Verify Email + @endcomponent + + If you did not create an account, no further action is required. +@endcomponent diff --git a/routes/web.php b/routes/web.php index 0c252b1..a62bda0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,13 +1,29 @@ middleware(['auth'])->name('verification.notice'); + + Route::get('/email/verify/{id}/{hash}', [VerifyEmailController::class, '__invoke']) + ->middleware(['auth', 'signed']) + ->name('verification.verify'); + + Route::post('/email/verification-notification', [EmailVerificationNotificationController::class, 'store']) + ->middleware(['auth', 'throttle:6,1']) + ->name('verification.send'); +} Route::get('/', function () { return view('welcome'); }); -Route::middleware(['auth'])->group(function () { +Route::middleware(['auth', 'verified'])->group(function () { Route::get('/dashboard', function () { return view('dashboard.home'); })->name('dashboard');