-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Admin feature: Nuke user #2977
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
Admin feature: Nuke user #2977
Changes from 6 commits
adeca3d
6c94e85
6ca118d
79d832d
e84f5fd
c3ede23
ecb383c
7252628
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| from warehouse.accounts.models import User, Email | ||
| from warehouse.packaging.models import Role | ||
| from warehouse.utils.paginate import paginate_url_factory | ||
| from warehouse.utils.project import remove_project | ||
|
|
||
|
|
||
| @view_config( | ||
|
|
@@ -125,3 +126,23 @@ def user_detail(request): | |
| return HTTPSeeOther(location=request.current_route_path()) | ||
|
|
||
| return {"user": user, "form": form, "roles": roles} | ||
|
|
||
|
|
||
| @view_config( | ||
| route_name='admin.user.delete', | ||
| require_methods=['POST'], | ||
| permission='admin', | ||
| uses_session=True, | ||
| require_csrf=True, | ||
| ) | ||
| def user_delete(request): | ||
| user = request.db.query(User).get(request.matchdict['user_id']) | ||
|
|
||
| # Delete projects one by one so they are purged from the cache | ||
| for project in user.projects: | ||
| remove_project(project, request, flash=False) | ||
|
|
||
| request.db.delete(user) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will implicitly cascade to their associated emails? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also probably want a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this will delete emails and roles for that user. I thought about adding a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair, but I would like some record of this feature being used. the journal is freeform. we should just write something to note that an admin used this feature. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would work and can't collide with project names. |
||
| request.session.flash(f'Nuked user {user.username!r}.', queue='success') | ||
|
|
||
| return HTTPSeeOther(request.route_path('admin.user.list')) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a
JournalEntryThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already a
JournalEntryhappening inremove_project.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmed, sorry I tested the button locally on a user with no projects :)