diff --git a/.gitignore b/.gitignore index 2658999..508a04d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ yarn-error.log /.fleet /.idea /.vscode +!storage/app/*.json + diff --git a/ESP8266_DHT11_FIREBASE/ESP8266_DHT11_FIREBASE.ino b/ESP8266_DHT11_FIREBASE/ESP8266_DHT11_FIREBASE.ino index 029b885..329c9e4 100644 --- a/ESP8266_DHT11_FIREBASE/ESP8266_DHT11_FIREBASE.ino +++ b/ESP8266_DHT11_FIREBASE/ESP8266_DHT11_FIREBASE.ino @@ -1,4 +1,4 @@ -#include + #include #include #include diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php new file mode 100644 index 0000000..477641d --- /dev/null +++ b/app/Http/Controllers/ProfileController.php @@ -0,0 +1,51 @@ + Auth::user() + ]); + } + + public function update(Request $request) + { + $request->validate([ + 'email' => 'required|email', + 'current_password' => 'required_with:new_password', + 'new_password' => 'nullable|min:8|confirmed', + 'profile_photo' => 'nullable|image|mimes:jpeg,png,jpg|max:2048' + ]); + + $user = Auth::user(); + $user->email = $request->email; + + // Handle password change + if ($request->new_password) { + if (!Hash::check($request->current_password, $user->password)) { + return back()->withErrors(['current_password' => 'Current password is incorrect']); + } + $user->password = Hash::make($request->new_password); + } + + // Handle profile photo + if ($request->hasFile('profile_photo')) { + $photo = $request->file('profile_photo'); + + // Replace existing foto.jpg + $photo->move(public_path('asset'), 'foto.jpg'); + } + + $user->save(); + + return redirect()->back()->with('success', 'Profile updated successfully'); + } +} \ No newline at end of file diff --git a/app/Providers/FirebaseServiceProvider.php b/app/Providers/FirebaseServiceProvider.php index acea1ae..7884b1a 100644 --- a/app/Providers/FirebaseServiceProvider.php +++ b/app/Providers/FirebaseServiceProvider.php @@ -13,16 +13,16 @@ public function register() { $this->app->singleton(FirebaseAuth::class, function ($app) { $factory = (new Factory) - ->withServiceAccount(json_decode(env('FIREBASE_CREDENTIALS'), true)) - ->withDatabaseUri(env('FIREBASE_DATABASE_URL')); + ->withServiceAccount(storage_path('app/smartcab-8bb42-firebase-adminsdk-fbsvc-de33a8e45b.json')) + ->withDatabaseUri(env('FIREBASE_DATABASE_URL')); return $factory->createAuth(); }); $this->app->singleton(Database::class, function ($app) { $factory = (new Factory) - ->withServiceAccount(config('firebase.credentials')) - ->withDatabaseUri(config('firebase.database_url')); + ->withServiceAccount(storage_path('app/smartcab-8bb42-firebase-adminsdk-fbsvc-de33a8e45b.json')) + ->withDatabaseUri(env('FIREBASE_DATABASE_URL')); return $factory->createDatabase(); }); diff --git a/resources/views/profile.blade.php b/resources/views/profile.blade.php new file mode 100644 index 0000000..573a018 --- /dev/null +++ b/resources/views/profile.blade.php @@ -0,0 +1,119 @@ + + + + + + Profile - SmartCab + + + +
+
+ +
+

Your Profile

+ + Back to Dashboard + +
+ + @if(session('success')) +
+ {{ session('success') }} +
+ @endif + + @if($errors->any()) +
+
    + @foreach($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif + +
+ @csrf + + +
+ +
+
+ Current profile photo +
+ +
+
+ + +
+ + +
+ + +
+

Change Password

+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+
+
+ + +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index e6ac1a7..fd06c6b 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -301,21 +301,130 @@ class="fixed inset-y-0 left-0 w-full max-w-xs bg-white dark:bg-gray-800 overflow - - - - + + + diff --git a/routes/web.php b/routes/web.php index 5985555..7952e23 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,6 +4,7 @@ use App\Http\Controllers\Auth\FirebaseAuthController; use App\Http\Controllers\AIChatController; use App\Http\Controllers\WelcomeController; +use App\Http\Controllers\ProfileController; Route::get('/login', [FirebaseAuthController::class, 'showLogin']) ->name('login') @@ -30,3 +31,6 @@ } return view('auth.login'); }); + +Route::get('/profile', [ProfileController::class, 'index'])->name('profile'); +Route::post('/profile/update', [ProfileController::class, 'update'])->name('profile.update');