Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix: use correct deletion function for inactive users #3165

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

ygerlach
Copy link
Contributor

I have seen the code deleting inactive users in the AccountDeletionController. It misses the parts of deleting a user as seen in UserController::deleteUserAccount (ProfilePicture and DatabaseNotification).

Im not a laravel expert, but i believe this might be a bug keeping ProfilePictures and Notifications for deleted users. If this problem is real, we may need to create a migration that checks the Database for non deleted profile pictures and notification objects, as this might be a privacy concern.

@MrKrisKrisu
Copy link
Member

but i believe this might be a bug keeping ProfilePictures and Notifications for deleted users. If this problem is real, we may need to create a migration that checks the Database for non deleted profile pictures and notification objects, as this might be a privacy concern.

Notifications are automatically deleted after a certain amount of time. As for profile pictures, we have a script that periodically deletes any that are not associated with an account. So this should not be an acute problem.

public function handle(): void {
$usedPictures = User::select('avatar')->distinct()->get()->pluck('avatar')->filter()->toArray();
$profilePictures = new \FilesystemIterator(public_path("uploads/avatars"));
foreach ($profilePictures as $profilePicture) {
if (!in_array(basename($profilePicture), $usedPictures)) {
File::delete($profilePicture);
$this->info('Deleted profile picture ' . basename($profilePicture));
}
}
}

@ygerlach
Copy link
Contributor Author

ok, so the data should be gone anyways. But i guess deleting it directly wouldn't hurt?

@MrKrisKrisu
Copy link
Member

ok, so the data should be gone anyways. But i guess deleting it directly wouldn't hurt?

Nope, should be done like this. Can you please have a look at the tests, as currently the code is broken and I cannot merge it.

Also - did you test it?

@ygerlach
Copy link
Contributor Author

Also - did you test it?

No. As i didn't manage to get a working dev setup yet.

I was just posting this MR as a discussion question, i didn't expect such a fast response.

Copy link
Member

@MrKrisKrisu MrKrisKrisu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also - did you test it?

No.

Works on my machine - thanks. :)

@MrKrisKrisu MrKrisKrisu merged commit 2f34406 into Traewelling:develop Jan 17, 2025
6 checks passed
@ygerlach ygerlach deleted the deleteUserAccount branch January 17, 2025 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants