diff --git a/laravel/app/Http/Controllers/ProfileController.php b/laravel/app/Http/Controllers/ProfileController.php new file mode 100644 index 0000000..4e7514b --- /dev/null +++ b/laravel/app/Http/Controllers/ProfileController.php @@ -0,0 +1,46 @@ +validate([ + 'name' => [ + 'required', + 'string', + 'max:28', + Rule::unique('users')->ignore($user->id), // Ignore current user + ], + 'email' => [ + 'required', + 'string', + 'email', + Rule::unique('users')->ignore($user->id), // Ignore current user + ], + ]); + } catch (ValidationException $e) { + return redirect()->back()->withInput($request->input())->withErrors($e->errors()); + } + $user->name = $request->input('name'); + $user->email = $request->input('email'); + $user->save(); + return redirect('profile')->with('success', 'Profile updated successfully'); + } + + public function updatePassword(Request $request) { + $user = Auth::user(); + $request->validate([ + 'password' => 'required|string|min:8|confirmed' + ]); + $user->password = bcrypt($request->input('password')); + $user->save(); + return redirect('profile')->with('success', 'Password updated successfully'); + } +} \ No newline at end of file diff --git a/laravel/public/css/default.css b/laravel/public/css/default.css index 9920325..07b3965 100644 --- a/laravel/public/css/default.css +++ b/laravel/public/css/default.css @@ -93,6 +93,16 @@ header nav a { box-shadow: 3px 3px 10px 0 #0008; } +#profile-container { + margin: 5vh auto; +} + +.button-row { + display: flex; + flex-direction: row; + justify-content: space-around; +} + .form-container form { display: flex; flex-direction: column; @@ -108,6 +118,12 @@ header nav a { margin-bottom: 20px; } +.form-container form input.unmodifiable { + color: #aaa; + border: none; + pointer-events: none; +} + .form-container form label { color: #666; font-size: 0.8em; @@ -139,6 +155,16 @@ header nav a { background: #ff000028; border-radius: 5px; padding: 10px; + margin-bottom: 0; +} + +.form-container .success { + width: 280px; + color: #00bb00; + background: #00ff0028; + border-radius: 5px; + padding: 10px; + margin-bottom: 0; } #banner-container { @@ -367,6 +393,11 @@ header nav a { #destination { max-width: 850px; + word-break: break-all; + height: 1.2em; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; } button { diff --git a/laravel/resources/views/details.blade.php b/laravel/resources/views/details.blade.php index 92b89f3..3ea6e48 100644 --- a/laravel/resources/views/details.blade.php +++ b/laravel/resources/views/details.blade.php @@ -19,9 +19,9 @@ @csrf