From 8c61a702e4907c643d73e70527372472e984f42d Mon Sep 17 00:00:00 2001
From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com>
Date: Fri, 25 Oct 2024 22:29:35 +0800
Subject: [PATCH 1/9] Update web.php

---
 routes/web.php | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/routes/web.php b/routes/web.php
index 71d04297..a61ae44b 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -20,8 +20,10 @@
 Route::get('users', [\App\Http\Controllers\UserController::class, 'index'])->name('users.index');
 
 // Task: profile functionality should be available only for logged-in users
+Route::middleware('auth')->group(function(){
 Route::get('profile', [\App\Http\Controllers\ProfileController::class, 'show'])->name('profile.show');
 Route::put('profile', [\App\Http\Controllers\ProfileController::class, 'update'])->name('profile.update');
+});
 
 // Task: this "/secretpage" URL should be visible only for those who VERIFIED their email
 // Add some middleware here, and change some code in app/Models/User.php to enable this

From 778979a7f79e65eaa18218faa83dbec274c8be26 Mon Sep 17 00:00:00 2001
From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com>
Date: Fri, 25 Oct 2024 22:30:15 +0800
Subject: [PATCH 2/9] Update navigation.blade.php

---
 resources/views/layouts/navigation.blade.php | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/resources/views/layouts/navigation.blade.php b/resources/views/layouts/navigation.blade.php
index 785936e7..6323af4c 100644
--- a/resources/views/layouts/navigation.blade.php
+++ b/resources/views/layouts/navigation.blade.php
@@ -16,9 +16,11 @@
                         {{ __('Users') }}
                     </x-nav-link>
                     {{-- Task: this "Profile" link should be visible only to logged-in users --}}
+                    @auth
                     <x-nav-link href="/profile" :active="request()->routeIs('profile.show')">
                         {{ __('Profile') }}
                     </x-nav-link>
+                    @endauth
                 </div>
             </div>
 

From bbef7001edcec2c638c7fa0153951b698651a5db Mon Sep 17 00:00:00 2001
From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com>
Date: Fri, 25 Oct 2024 22:31:22 +0800
Subject: [PATCH 3/9] Update profile.blade.php

---
 resources/views/auth/profile.blade.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/resources/views/auth/profile.blade.php b/resources/views/auth/profile.blade.php
index 70e8a8e1..27ab8a1b 100644
--- a/resources/views/auth/profile.blade.php
+++ b/resources/views/auth/profile.blade.php
@@ -29,7 +29,7 @@
                                      class="block mt-1 w-full"
                                      type="text"
                                      name="name"
-                                     value="???"
+                                     value="{{auth()->user()->name}}"
                                      required />
                         </div>
 
@@ -40,7 +40,7 @@ class="block mt-1 w-full"
                                      class="block mt-1 w-full"
                                      type="email"
                                      name="email"
-                                     value="???"
+                                     value="{{auth()->user()->email}}"
                                      required />
                         </div>
 

From be3d940200748b7cc7e1148d745bbebb07ff3f3c Mon Sep 17 00:00:00 2001
From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com>
Date: Fri, 25 Oct 2024 22:33:42 +0800
Subject: [PATCH 4/9] Update ProfileController.php

---
 app/Http/Controllers/ProfileController.php | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index e0093a49..aece3c21 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Http\Requests\ProfileUpdateRequest;
+use Illuminate\Support\Facade\Hash;
 
 class ProfileController extends Controller
 {
@@ -15,6 +16,12 @@ public function update(ProfileUpdateRequest $request)
     {
         // Task: fill in the code here to update name and email
         // Also, update the password if it is set
+        $user=auth()->user();
+        $user->update($request->safe()->only(['name','email']));
+        if($request->filled('password')){
+            $user->update(['password'=>Hash::make($request->password)]);
+        }
+            
 
         return redirect()->route('profile.show')->with('success', 'Profile updated.');
     }

From 345f7bf4aca20e6d69b3c8521317eab6c0949c6d Mon Sep 17 00:00:00 2001
From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com>
Date: Fri, 25 Oct 2024 22:34:20 +0800
Subject: [PATCH 5/9] Update web.php

---
 routes/web.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/routes/web.php b/routes/web.php
index a61ae44b..7901877e 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -27,7 +27,7 @@
 
 // Task: this "/secretpage" URL should be visible only for those who VERIFIED their email
 // Add some middleware here, and change some code in app/Models/User.php to enable this
-Route::view('/secretpage', 'secretpage')
+Route::view('/secretpage', 'secretpage')->middleware(['auth','verified'])
     ->name('secretpage');
 
 // Task: this "/verysecretpage" URL should ask user for verifying their password once again

From 990762dfa75766805181a6562c90336fdf1dc415 Mon Sep 17 00:00:00 2001
From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com>
Date: Fri, 25 Oct 2024 22:35:06 +0800
Subject: [PATCH 6/9] Update User.php

---
 app/Models/User.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/Models/User.php b/app/Models/User.php
index e23e0905..12a2354b 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -8,7 +8,7 @@
 use Illuminate\Notifications\Notifiable;
 use Laravel\Sanctum\HasApiTokens;
 
-class User extends Authenticatable
+class User extends Authenticatable implements MustVerifyEmail
 {
     use HasApiTokens, HasFactory, Notifiable;
 

From 9de30d387aa97b32dc2a22d7d8e8f9785df7e7af Mon Sep 17 00:00:00 2001
From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com>
Date: Fri, 25 Oct 2024 22:36:49 +0800
Subject: [PATCH 7/9] Update web.php

---
 routes/web.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/routes/web.php b/routes/web.php
index 7901877e..d89d89f7 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -32,7 +32,7 @@
 
 // Task: this "/verysecretpage" URL should ask user for verifying their password once again
 // You need to add some middleware here
-Route::view('/verysecretpage', 'verysecretpage')
+Route::view('/verysecretpage', 'verysecretpage')->middleware('password.confirm')
     ->name('verysecretpage');
 
 require __DIR__.'/auth.php';

From e9a13d05ab59a3834f2c7605f3bc8481139576ff Mon Sep 17 00:00:00 2001
From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com>
Date: Fri, 25 Oct 2024 22:38:24 +0800
Subject: [PATCH 8/9] Update RegisteredUserController.php

---
 app/Http/Controllers/Auth/RegisteredUserController.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php
index d8d29eb5..208d9a24 100644
--- a/app/Http/Controllers/Auth/RegisteredUserController.php
+++ b/app/Http/Controllers/Auth/RegisteredUserController.php
@@ -37,7 +37,7 @@ public function store(Request $request)
         $request->validate([
             'name' => ['required', 'string', 'max:255'],
             'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
-            'password' => ['required', 'confirmed', Rules\Password::defaults()],
+            'password' => ['required', 'confirmed', Rules\Password::min(8)->letters()],
         ]);
 
         $user = User::create([

From 41191cdcd02a388f6d18af5c427c7db543f8204e Mon Sep 17 00:00:00 2001
From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com>
Date: Fri, 25 Oct 2024 22:44:36 +0800
Subject: [PATCH 9/9] Update ProfileController.php

---
 app/Http/Controllers/ProfileController.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index aece3c21..b0e507c5 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -3,7 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Http\Requests\ProfileUpdateRequest;
-use Illuminate\Support\Facade\Hash;
+use Illuminate\Support\Facades\Hash;
 
 class ProfileController extends Controller
 {