Implement hard delete user
Created by: yishuotang
Description
Previous updates (2024/12):
UI updates:
- Delete User button moved from user management main page to modify user page.
- Added first and secondary deletion confirmation modals, ensuring intentional deletion. Displaying impact details and require username confirmation, reset user input on modal close.
- Deletion only happens when both username and delete option are provided.
Schema updates:
- Added/changed a few onDelete behavior rules to ensure proper cascading deletions and nullifications.
API updates:
- Implemented hardDeleteUser function in the service layer, leverage schema rules for efficient user deletion.
- New endpoint: Added and routed
DELETE /users/:username/delete
to the function for hard deletion.
Previous updates (2025/1):
UI updates:
- "Soft Deletion" is shown and selected by default.
- "Soft Deletion" option is hidden if the user is already soft-deleted.
- Error messages are inline msgs instead of toast notifications.
- Refactored delete options to use a boolean (isHardDelete) for cleaner logic, updated deleteUser function accordingly.
API updates:
- Unified DELETE endpoint (DELETE /users/:username) for both soft and hard deletes. -- Soft delete: DELETE /users/:username. -- Hard delete: DELETE /users/:username?hard_delete=true.
- Unified service layer function with an isHardDelete parameter.
New updates:
UI Updates:
- Refactored radio button group to use
<VaRadio>
instead of<input>
, updated related logic accordingly. - Hard delete is now selected by default when the user is already soft-deleted.
- Moved styles into the
<style>
block. - Displayed info message for disabled soft-deletion option using Vue’s list component inside the alert component.
- Ran linting on affected files.
API & Schema Updates:
- isHardDelete changed from string to boolean for cleaner logic.
- Implemented express-validator for request validation.
- Used a single interactive Prisma transaction for consistency.
- Updated services/user.js to provide query parameters as an object in api.delete.
Related Issue(s) Closes #45 (closed)
Changes Made
-
Feature added -
Bug fixed -
Code refactored -
Documentation updated -
Other changes: [describe]
Checklist
Before submitting this PR, please make sure that:
-
Your code passes linting and coding style checks. -
Documentation has been updated to reflect the changes. -
You have reviewed your own code and resolved any merge conflicts. -
You have requested a review from at least one team member. -
Any relevant issue(s) have been linked to this PR.