Fix delete account function & delete modal

This commit is contained in:
2026-01-08 19:28:44 +01:00
parent fb3722036a
commit ac853920ee
7 changed files with 64 additions and 43 deletions

View File

@@ -145,6 +145,13 @@ class ProfileController extends Controller
{
$user = $request->user();
// Verify password if user has password
if (!is_null($user->password)) {
$request->validateWithBag('userDeletion', [
'password' => ['required', 'current_password'],
]);
}
// Delete Playlist
$playlists = Playlist::where('user_id', $user->id)->get();
foreach($playlists as $playlist) {
@@ -155,6 +162,11 @@ class ProfileController extends Controller
// Update comments to deleted user
DB::table('comments')->where('commenter_id', '=', $user->id)->update(['commenter_id' => 1]);
// Delete Profile Picture
if ($user->avatar) {
Storage::disk('public')->delete($user->avatar);
}
Auth::logout();
$user->forceDelete();