mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-03 15:52:51 +00:00
fix: correct user deletion (#10385)
* Ensure all user sessions are cleared * remove double warning text on user delete
This commit is contained in:
@@ -144,6 +144,14 @@ class UserDetail(RetrieveUpdateDestroyAPI):
|
|||||||
serializer_class = ExtendedUserSerializer
|
serializer_class = ExtendedUserSerializer
|
||||||
permission_classes = [InvenTree.permissions.StaffRolePermissionOrReadOnly]
|
permission_classes = [InvenTree.permissions.StaffRolePermissionOrReadOnly]
|
||||||
|
|
||||||
|
def perform_destroy(self, instance):
|
||||||
|
"""Override destroy method to ensure sessions are deleted first."""
|
||||||
|
# Remove all sessions for this user
|
||||||
|
if sessions := instance.usersession_set.all():
|
||||||
|
sessions.delete()
|
||||||
|
# Normally delete the user
|
||||||
|
return super().perform_destroy(instance)
|
||||||
|
|
||||||
|
|
||||||
class UserDetailSetPassword(UpdateAPI):
|
class UserDetailSetPassword(UpdateAPI):
|
||||||
"""Allows superusers to set the password for a user."""
|
"""Allows superusers to set the password for a user."""
|
||||||
|
@@ -358,6 +358,7 @@ export function UserTable({
|
|||||||
title: t`Delete user`,
|
title: t`Delete user`,
|
||||||
successMessage: t`User deleted`,
|
successMessage: t`User deleted`,
|
||||||
table: table,
|
table: table,
|
||||||
|
preFormContent: <></>,
|
||||||
preFormWarning: t`Are you sure you want to delete this user?`
|
preFormWarning: t`Are you sure you want to delete this user?`
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user