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

Allow admins to delete users #368

Merged
merged 2 commits into from
Jan 1, 2025
Merged

Allow admins to delete users #368

merged 2 commits into from
Jan 1, 2025

Conversation

benjaminpjones
Copy link
Collaborator

Basically what the title says. Additionally, I pulled in the sweetalert2 library. This gives us ability to launch more advanced modals than window.alert(), which was necessary for the additional verification in the User deletion flow.

  1. Log in as admin

  2. Click "Delete User"

  3. Enter user's name as a safeguard
    Screenshot_20241231_195147
    3a) On failure, inform the admin
    Screenshot_20241231_195215
    3b) On success, inform the admin, then return home
    Screenshot_20241231_195239

callback(new Error(`No user with ID: ${id}`));
// This may be the case if a user has been deleted, but the user session persists.
// Sending null as the second argument invalidates the session.
callback(null, null);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without this change, the deleted user essentially gets "blacklisted" from the site: they just get the response body "No user with ID: ", until they clear their cache, which is not obvious to laypeople.

See also: jaredhanson/passport#6

@benjaminpjones
Copy link
Collaborator Author

Going to merge since this is only exposed to Admins, but @merowin brought up a good point offline - we should remove deleted players from their games as well.

I think this should be possible, and reasonably efficient using updateMany along with positional filtering

Until then - note to admins: only use this button if you are okay with their remnants lingering on games!

@benjaminpjones benjaminpjones merged commit 778f308 into main Jan 1, 2025
3 checks passed
@benjaminpjones benjaminpjones deleted the delete-users branch January 1, 2025 19:36
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